我刚接触Unity,在尝试通过我的脚本更新VideoPlayer。 我已经确认代码可以使用预设值运行,但是当我执行videoPlayer.url = "新的视频url"
时,它不会播放。
这是我的播放视频代码。 这将起作用,但是一旦我给它一个要更新的url,它只是更改了源但没有播放视频。
public IEnumerator playVideo(string videoYear) {
// This line updates the url but the video will not actually play.
videoPlayer.url = "example.com/app/" + videoYear + ".mp4";
videoPlayer.Prepare();
WaitForSeconds waitForSeconds = new WaitForSeconds(1);
while(!videoPlayer.isPrepared)
{
yield return waitForSeconds;
break;
}
rawImage.texture = videoPlayer.texture;
videoPlayer.Play();
}
http://
。 - Joe Scotto