我试图在Unity中倒带VideoPlayer,也正在使用新的VideoPlayer API和mp4.我尝试将播放速度设置为负数,但会暂停. 我当前的解决方案是
I am attempting to rewind a VideoPlayer in Unity, also I am using the new VideoPlayer API and an mp4. I have tried setting the playback speed to a negative number, but it pauses. My current solution is
在我的快退按钮脚本中:
void Update () { if (rewind == true) { VideoController.Backward2Seconds(); } }在我的VideoController脚本中
public void Backward2Seconds() { if (!IsPlaying) return; videoPlayer.time = videoPlayer.time - 2; }有更好的方法吗?因为太迟了.
Is there a better way? Because this is laggy.
推荐答案不幸的是,恐怕您的第一次尝试是最好的尝试,而只是您的平台不支持它.它可以在其他设备上运行.根据 VideoPlayer文档:
Unfortunately, I am afraid that your first try was the best one, and that it is just your platform that doesn't support it. It could work on other devices. According to the VideoPlayer doc:
对负值的支持取决于平台
Support for negative values is platform dependent
由于该解决方案似乎无法在您的设备上运行,因此,考虑到每个帧之间经过的时间,可能会改善您的解决方法.请尝试以下操作:
Since it seems that this solution doesn't work on your device, your workaround might be improved by taking in account the time that passed between each frame. Try the following:
在您的RewindButton脚本中
void Update () { if (rewind == true) { VideoController.Backward(Time.deltaTime); } }在您的VideoController脚本中
public float Speed; public void Backward(float deltaTime) { if (!IsPlaying) return; videoPlayer.time = videoPlayer.time - deltaTime*Speed; }这应该可以让您控制倒带的速度,同时产生更流畅的效果
This should allow you to control the speed of the rewind while having a more fluid effect
更多推荐
如何在Unity中倒带Video Player?
发布评论