// 视频播放器
[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
{
}
}
网友评论