如何在活动中暂停HTML5视频? [英] How to pause a HTML5 video on an event?
问题描述
我正在全屏背景下使用HTML5 - < video>
构建一个网站。有一些< div>
形状的页面在SWF容器播放器中变得可见,当两个媒体播放时都会导致严重的CPU性能问题。
所以我想添加一个简单的javascript命令,当项目 - < div>
变得可见时暂停背景视频。如果它在关闭/隐藏时再次恢复播放会很好。
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.
提前致谢。
推荐答案
document.getElementById('myvideotag').pause();
请注意,没有stop()方法。在显示/隐藏您的DIV的功能中,将播放/暂停功能放在那里。
Note that there is no stop() method. In the function that shows/hides your DIV, place the play/pause function there.
此处有更多资源: http://www.digitaria.com/blogs/html5-video-skinning-tutorial-part-2-play-buttons
这篇关于如何在活动中暂停HTML5视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!