// 視頻播放器
[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;
// 檢測(cè)當(dāng)前動(dòng)畫(huà)是否播放完成
// videoPlayer.loopPointReached += CheckOver;
}
//獲取商場(chǎng)路徑
public void OnUploadClick(UContent content, FPointerEventData data)
{
filePath = "";
filePath = EditorUtility.OpenFilePanel("upload file", "", fileExtension); // 自己選擇文件沈贝,獲取到Assets路徑
print(filePath);
if (filePath != "")
{
videoPlayer.url = filePath;
// 預(yù)覽視頻第一幀
PreviewVideo();
}else
{
}
}