如何在Unity中倒带Video Player?

编程入门 行业动态 更新时间:2024-10-24 06:25:08
本文介绍了如何在Unity中倒带Video Player?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图在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?

本文发布于:2023-07-11 09:17:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1093555.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   Unity   中倒带   Video   Player

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!