HTML5<视频>回调?视频>
我正在为客户开发一个网站,他们坚持使用 HTML5 的视频标签作为某些视频内容的交付方法。我目前已经在 http://videojs.com/ 的帮助下启动并运行它来处理 Internet Explorer Flash倒退。
他们要求我做的一件事是,在视频播放完毕后(它们的长度都不同),将它们淡出,然后淡出一张图片来代替视频——把它想象成一个海报框架视频。
这可能吗?您可以通过 Javascript 或其他方法获取当前正在播放的电影的时间码吗?我知道 Flowplayer (http://flowplayer.org/demos/scripting/grow.html )有一个 onFinish 函数,这是我应该采取的路线来代替 HTML5 视频方法吗? IE 用户将获得 Flash 播放器这一事实是否需要两个单独的解决方案?
任何意见将不胜感激。我目前在网站上使用 jQuery,因此如果可能的话,我希望将解决方案保留在该领域。谢谢!
I'm working on a site for a client and they're insistent on using HTML5's video tag as the delivery method for some of their video content. I currently have it up and running with a little help from http://videojs.com/ to handle the Internet Explorer Flash fallback.
One thing they've asked me to do is, after the videos finish playing (they're all a different length), fade them out and then fade a picture in place of the video --- think of it like a poster frame after the video.
Is this even possible? Can you get the timecode of a currently playing movie via Javascript or some other method? I know Flowplayer (http://flowplayer.org/demos/scripting/grow.html) has an onFinish function, is that the route I should take in lieu of the HTML5 video method? Does the fact that IE users will be getting a Flash player require two separate solutions?
Any input would be greatly appreciated. I'm currently using jQuery on the site, so I'd like to keep the solution in that realm if at all possible. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以在规范中查看完整的事件列表在这里。
例如:
您可以像 jQuery 中的其他任何内容一样绑定到元素上的事件...至于您的评论问题,无论您为 IE 提供什么元素,是的,它都需要一个单独的处理程序来处理它提供的任何事件。
对于有关时间码的另一个问题,
timeupdate
事件在播放时发生,durationchange
事件在整体持续时间更改时发生。您可以绑定并使用它们,就像我在上面的ending
事件中展示的那样。对于timeupdate
,您可能需要currentTime
属性,对于durationchange
,您可能需要duration
属性,每个你可以直接从 DOM 对象中获取其中的内容,如下所示:You can view a complete list of events in the spec here.
For example:
You can bind to the event on the element like anything else in jQuery...as for your comment question, whatever element you're delivering for IE, yes, it would need a separate handler rigged up to whatever event it provides.
For the other question about timecode, the
timeupdate
event occurs when it's playing, and thedurationchange
event occurs when the overall duration changes. You can bind to and use them just like I showed with theended
event above. Withtimeupdate
you'll probably want thecurrentTime
property, withdurationchange
you'll want theduration
property, each of which you get directly off the DOM object, like this:有一个与视频标签关联的 OnEnded 事件。但是,它在当前版本的 Google Chrome 中对我不起作用。
HTML 5 视频 OnEnded 事件未触发
另请参阅
检测 HTML5 视频何时结束
对于通用解决方案(支持带有回退功能的视频标记请参阅)
http://camendesign.com/code/video_for_everybody
或者
http://www.kaltura.org/project/HTML5_Video_Media_JavaScript_Library 或 http://www.mediafront.org/
There is an OnEnded event associated with the video tag. However, it does not work for me in the current version of Google Chrome.
HTML 5 Video OnEnded Event not Firing
and see also
Detect when an HTML5 video finishes
For a general-purpose solution (supports video tag with fallback see)
http://camendesign.com/code/video_for_everybody
or
http://www.kaltura.org/project/HTML5_Video_Media_JavaScript_Library or http://www.mediafront.org/
我用了这段代码。它基本上会重新加载视频,从而使海报再次显示。假设您希望最后的图像与海报相同。我页面上只有一个视频,因此可以使用视频标签。我将视频设置为在页面加载时自动播放,因此我在重新加载后添加了暂停。
I used this code. It basically reloads the video which will get the poster to show again. Assuming you want the image at the end to be the same as the poster. I only have one video on the page so using the video tag works. I have my video set to autoplay on page load so I added the pause after the reload.