在 iOS 上向后播放 HTML5 视频
我正在尝试在 iPad 上反向播放 HTML5 视频(视频需要根据用户输入在正向和反向之间任意切换)。
HTML5 元素包含一个名为
playbackRate
的属性,该属性允许视频以更快、更慢的速率或反向播放。根据 Apple 文档,iOS 不支持此属性。
通过每秒多次设置 currentTime
属性(例如每秒 10-30 次更新),可以在不使用 playbackRate
的情况下伪造反向播放。这种方法适用于桌面 Safari,但似乎 iOS 设备上的搜索上限为每秒 1 次更新左右 - 在我的情况下太慢了。
有没有办法在 iOS 设备(即 iPad)上向后播放 HTML5 视频?
(我正在运行 4.3.1 的 iPad 2 上进行测试)
I'm trying to play an HTML5 video in reverse on an iPad (The video needs to switch between forward and reverse arbitrarily based on user input).
The HTML5 <video>
element includes a property called playbackRate
which allows video to be played at a faster or slower rate, or in reverse. According to Apple's documentation, this property is not supported on iOS.
Playing in reverse can be faked without the use of playbackRate
by setting the currentTime
property multiple times per second (e.g. 10-30 updates per second). This approach works on desktop Safari but it seems that seeking is capped on iOS devices to around 1 update per second - too slow in my case.
Is there any way to play an HTML5 video backward on an iOS device (namely an iPad)?
(I'm testing on an iPad 2 running 4.3.1)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
正如 Mihai 建议的那样,使用两个版本并在用户更改播放方向时更新搜索位置。
将 DIV 中的视频一层一层地分层,当播放方向翻转时,切换 div 可见性(并暂停隐藏视频的播放)。
这就是时间线:
As Mihai suggested, use the two versions and update the seek location when the user changes the playback direction.
Layer the videos in DIVs on top of one another, and when the playback direction is flipped, toggle the div visibility (and pause playback of the the one being hidden).
So this is the timeline:
iOS 6 Safari 现在支持
playbackRate
属性。The
playbackRate
attribute is now supported on iOS 6 Safari.为什么不把正向和反向版本拼接成一部电影呢?
这消除了用户翻转方向时卸载和加载视频的问题。使用单电影方法,当用户翻转方向时,您所需要做的就是找出电影另一半中的对应点并寻找那里。
Why not stitch the reverse and forward versions together into one movie?
That removes the problem of unloading and loading video when the user flips the direction. With a single movie approach, when the user flips direction, all you need to do is figure out the corresponding point in the other half of the movie and seek to there.
我的建议是在 HTML 代码中制作一个“假”视频播放器。然后捕获用户使用 safari/ios 回调方法“播放”视频的尝试。然后创建一个 MPMoviePlayerController,它实际加载视频并将其显示在浏览器中视频的原始位置上或仅支持全屏播放。 MPMediaPlayback 协议通过 currentPlaybackRate 属性支持反向播放,因此希望这应该是一个临时修复,因为我看不到 iOS 版本的 Safari最终没有实现此功能,因为它受到本机播放器的支持。
My suggestion is to make a "fake" video player in your HTML code. Then capture the user's attempt to "play" the video using the safari/ios callback methods. Then create a MPMoviePlayerController that actually loads the video and display it over the original position of the video in the browser or only support full screen play. MPMediaPlayback protocol supports reverse playback via the currentPlaybackRate property so hopefully, this should be a temporary fix as I can't see the iOS version of Safari not eventually implementing this feature since it is supported by the native player.
注意:我很愚蠢,错过了问题的重要部分,因此以下内容对于 iOS 目的来说毫无用处
经过一番谷歌搜索后,我发现了以下代码以及有关如何支持的解释在基于 Webkit 的浏览器上反向播放 html5 视频:
来源:http://net. tutsplus.com/tutorials/html-css-techniques/html5-audio-and-video-what-you-must-know/
您需要将html5视频对象传递给加速函数,但是然后,该功能可能会简化为以下内容(我还没有测试过,这是 iPad 特定的功能):
随意尝试,并搜索有关 html5 视频元素的更多信息:)
NOTE: I was stupid and missed a non-trivial part of the question, so the following is pretty useless for iOS purposes
After a moment of Googling, I found the following code along with explanation on how to support reverse-playback of html5 video on Webkit based browsers:
Source: http://net.tutsplus.com/tutorials/html-css-techniques/html5-audio-and-video-what-you-must-know/
You need to pass in the html5 video object to the speedup function, but then again that function could possibly be reduced into the following (I haven't tested this yet, it is an iPad specific function):
Feel free to play around, and search for more information on the html5 video element :)