如何在活动中暂停 HTML5 视频?
我正在全屏背景下构建一个使用 HTML5- 的网站。有些
形状的页面在使用 SWF 容器播放器时变得可见,这会在播放两种媒体时导致严重的 CPU 性能问题。 因此,我想添加一个简单的 javascript 命令,当项目
变得可见时,该命令会暂停背景视频。如果它在关闭/隐藏时再次恢复播放,那就太好了。提前致谢。
I am building a website with HTML5-<video>
in fullscreen background. There are pages in shape of <div>
s becoming visible with SWF-container player in them that cause serious CPU performance issues when both media play.
So I want to add a simple javascript command that pauses the background video when a project-<div>
becomes visible. Would be nice if it resumes again the playback when it gets closed/hidden.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
请注意,没有 stop() 方法。在显示/隐藏 DIV 的函数中,将播放/暂停函数放在那里。
更多资源:http://www.digitaria.com/blogs/ html5-video-skinning-tutorial-part-2-play-buttons
Note that there is no stop() method. In the function that shows/hides your DIV, place the play/pause function there.
More resources here: http://www.digitaria.com/blogs/html5-video-skinning-tutorial-part-2-play-buttons
我个人最喜欢的是添加到 html 属性中的一个小型 onclick 处理程序,如下所示:
My personal favourite is a small onclick handler added to html attribute, like this:
由于 div 隐藏/显示上没有传统事件,因此当您调用使 div 出现/消失的函数时,您必须播放()和暂停()您的视频元素
since there are not traditional events on div hide/show you have to play() and pause() your video element when you call the functions that make your div appear/disappear