问题一:发布到WebGL端并能播放视频。(目前测试原生的就只发现ogv可以播放,其他的需要使用其他操作才可以播放)
videoPlayer.url = Application.streamingAssetsPath + "/早.ogv";
问题二:发布到PC端并能播放视频。(目前测试原生的就只发现mp4可以播放,其他的需要使用其他操作才可以播放)
videoPlayer.url = Application.streamingAssetsPath + "/早.mp4";
我这里都是用的streamingAsset加载的。
问题三:打包出来有时候会出现黑屏的情况。
public class VideoBlack : MonoBehaviour
{
private VideoPlayer video;
void Start()
{
video = GetComponent<VideoPlayer>();
}
void Update()
{
if (video.clip != null)
{
if (video.frame >= ((long)video.frameCount - 2))//相当于判断是否到了倒数第二帧
{
video.frame = 0;
}
}
}
}
把这个代码挂载在有VideoPlayer组件的物体上就可以了。
问题四:在ui上面播放视频。
如上图所示,创建一个rawimage和一个renderTextrue就可以播放了。