当我们关闭叠加层时,YouTube 视频不会停止
我正在使用 jQuery 模型窗口打开 YouTube 视频。在 IE、Safari、Chrome 中,当我们关闭覆盖层时,YouTube 视频不会在那里停止,而是继续在后台播放,然后与其他视频产生问题。
我的示例代码是
<div id="boxes">
<div class="window" id="dialog" style="top: 11px; left: 323.5px; display: block;">
<div align="right" class="clsbtn"><a class="close" href="#">Close</a></div>
<div>
<object width="580" height="360">
<param name="movie" value="http://www.youtube.com/v/eiz2vkSwSeQ&hl=en_US&fs=1&border=1"></param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/eiz2vkSwSeQ&hl=en_US&fs=1&border=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="580" height="360"></embed>
</object>
</div>
</div>
<div class="window" id="dialog" style="top: 11px; left: 323.5px; display: block;"></div>
</div>
<script>
$('.window .close').click(function (e) {
//Cancel the link behavior
e.preventDefault();
$('#mask').hide();
$('#mask').css("opacity",0);
$('.window').hide();
});
$('#mask').click(function () {
$('#mask').css("opacity",0);
$(this).hide();
$('.window').hide();
});
</script>
当我单击缩略图时,叠加层将打开并且相应的视频将自动播放。但我不知道当我们关闭叠加层时如何停止视频。
I am using to open a you tube video in jQuery Model Window.In IE, Safari, Chrome When we close the overlay the YouTube video doesn't stop there but keeps playing in background and then create issues with other video.
My sample Code is
<div id="boxes">
<div class="window" id="dialog" style="top: 11px; left: 323.5px; display: block;">
<div align="right" class="clsbtn"><a class="close" href="#">Close</a></div>
<div>
<object width="580" height="360">
<param name="movie" value="http://www.youtube.com/v/eiz2vkSwSeQ&hl=en_US&fs=1&border=1"></param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/eiz2vkSwSeQ&hl=en_US&fs=1&border=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="580" height="360"></embed>
</object>
</div>
</div>
<div class="window" id="dialog" style="top: 11px; left: 323.5px; display: block;"></div>
</div>
<script>
$('.window .close').click(function (e) {
//Cancel the link behavior
e.preventDefault();
$('#mask').hide();
$('#mask').css("opacity",0);
$('.window').hide();
});
$('#mask').click(function () {
$('#mask').css("opacity",0);
$(this).hide();
$('.window').hide();
});
</script>
When I click the thumbnail image the overlay will open and the respective video will play automatically. But I don't know how to stop the the video when we close the overlay.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
或者您可以直接链接到它:
Or you can link to it directly:
将
对象
保存到js变量中。然后,当您打开模态时,使用
html(nameOfObjectVar)
添加它,当有人关闭模态时,您remove()
它。这就是我在一个有模态视频的网站上所做的。
比尝试使用 YT
stopVideo()
更好,谁知道 Google 何时会改变这一点。Keep the
object
into a js variable.Then when you open modal, add it using
html(nameOfObjectVar)
and when someone close the modal, youremove()
it.That's what I did in a website that had a video in a modal.
Better than trying to use YT
stopVideo()
which who knows when Google might change that.