美文网首页
软件打开外部视频,用外部播放器,定时关闭

软件打开外部视频,用外部播放器,定时关闭

作者: 不过一书生 | 来源:发表于2019-04-26 14:03 被阅读0次

1.unity设置需要勾选后台运行;

2.我用的是4L-lite播放器;

代码如下:

void Start ()

    {

        Process.Start("D:\\Video-1\\1-1.mp4");//开始外部视频

        StartCoroutine(CloseVideoFunction());

}

// Update is called once per frame

void Update ()

    {

}

    IEnumerator  CloseVideoFunction()//关闭视频播放器

    {

        yield return new WaitForSeconds(5f);

        ToKillProcessFunction("mpc-hc64_nvo");

    }

    private void ToKillProcessFunction(string name)关闭方法

    {

        Process[] ps = Process.GetProcessesByName(name);

        foreach(var item in ps)

        {

            print("kill");

            item.Kill();

        }

    }

播放器地址:

链接:https://pan.baidu.com/s/1xZszaKNYeNCxIh9pJ9-S0w

提取码:n276

相关文章

网友评论

      本文标题:软件打开外部视频,用外部播放器,定时关闭

      本文链接:https://www.haomeiwen.com/subject/jqyfnqtx.html