美文网首页
播放本地视频,以及第一帧渲染

播放本地视频,以及第一帧渲染

作者: guoss | 来源:发表于2020-05-08 09:32 被阅读0次

    // 视频播放器
    [SerializeField] private UnityEngine.Video.VideoPlayer videoPlayer;
    // 视频textture容器
    [SerializeField] private UnityEngine.UI.RawImage rawImage;

    第一帧渲染
    IEnumerator ShowVideoFirstFrame()
        {
            videoPlayer.time = 0;
            videoPlayer.Prepare();
            WaitForSeconds waitForSeconds = new WaitForSeconds(1);
            while (!videoPlayer.isPrepared)
            {
                yield return waitForSeconds;
                break;
            }
            videoPlayer.Play();
            rawImage.texture = videoPlayer.texture;
            videoPlayer.Pause();
        }
    
    //视频播放
    void PlayVideo()
        {
            videoPlayer.Play();
            rawImage.texture = videoPlayer.texture;
            // 检测当前动画是否播放完成
            // videoPlayer.loopPointReached += CheckOver;
    
        }
    
    //获取商场路径
    public void OnUploadClick(UContent content, FPointerEventData data)
        {
            filePath = "";
            filePath = EditorUtility.OpenFilePanel("upload file", "", fileExtension);  // 自己选择文件,获取到Assets路径
            print(filePath);
            if (filePath != "")
            {
                videoPlayer.url = filePath;
                // 预览视频第一帧
                PreviewVideo();
            }else
            {
                
            }
    
        }
    

    相关文章

      网友评论

          本文标题:播放本地视频,以及第一帧渲染

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