如何在活动中暂停 HTML5 视频?

发布于 2024-10-02 01:20:45 字数 274 浏览 1 评论 0原文

我正在全屏背景下构建一个使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

凤舞天涯 2024-10-09 01:20:45
document.getElementById('myvideotag').pause();

请注意,没有 stop() 方法。在显示/隐藏 DIV 的函数中,将播放/暂停函数放在那里。

更多资源:http://www.digitaria.com/blogs/ html5-video-skinning-tutorial-part-2-play-buttons

document.getElementById('myvideotag').pause();

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

谁把谁当真 2024-10-09 01:20:45

我个人最喜欢的是添加到 html 属性中的一个小型 onclick 处理程序,如下所示:

<video onclick="this.paused? this.play() : this.pause()">

My personal favourite is a small onclick handler added to html attribute, like this:

<video onclick="this.paused? this.play() : this.pause()">
尛丟丟 2024-10-09 01:20:45

由于 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文