[英]How to stop html5 video when closing its inline popup, cross-browser
Hello fellow coders i come to you in a time of need. 您好,我的编码员在需要的时候找您。 I have an inline popup containing html5 videos.
我有一个内嵌弹出式窗口,其中包含html5视频。 i added a stop('#video');
我添加了一个stop('#video'); to the "close popup" function and this works, but only in Chrome and Opera, not in Firefox and EI, which leads me to a sub question, based on the same code, can anyone se a reason why the video wont load properly in Opera and Safari.
到“关闭弹出窗口”功能,此方法有效,但仅在Chrome和Opera中有效,而在Firefox和EI中无效,这使我想出一个基于相同代码的子问题,任何人都可以找出视频无法正确加载的原因Opera和Safari。 I cant for the life of me figure out why and im hoping one of you can.
我无法为自己的一生找出原因,并希望你们中的一个可以。
HTML: HTML:
<section id="video">
<a href="#" class="topopup">
<img src="images/play.png" alt="Play company video" title="Play company Video"/>
</a>
<div id="toPopup">
<div class="close"></div>
<div id="popup_content">
<video width="100%" height="auto" controls>
<source src="video/AM1.mp4" type="video/mp4">
<source src="video/AM2.webm" type="video/webm">
<source src="video/AM3.ogg" type="video/ogg">
Video format not supported by your browser
</video>
</div>
</div>
</div>
<div id="backgroundPopup"></div>
</section>
CSS: CSS:
#video {
background: #ecf0f1;
/*light gray*/
}
#video img {
width: 36.11%;
max-width: 252px;
}
#backgroundPopup {
position: fixed;
display:none;
height:100%;
width:100%;
background:#000000;
top:0px;
left:0px;
}
#toPopup {
background: none repeat scroll #000;
margin-left:10%;
margin-right:10%;
height:auto;
display: none;
position: fixed;
top: 10%;
z-index: 1;
}
JavaScript: JavaScript的:
$(this).keyup(function (event) {
if (event.which == 27) // 27 is 'Ecs' in the keyboard
disablePopup(); // function close pop up
});
$(this).keyup(function (event) {
if (event.which == 27) stop('#video');
});
$("div#backgroundPopup").click(function () {
disablePopup(); // close pop up
});
$("div#backgroundPopup").click(function () {
stop('#video'); // stop video
});
Uh, I'm a bit puzzled how your stop
function worked anywhere at all--the way to stop an HTML5 video is by using DOMNode.pause()
. 嗯,我有点困惑您的
stop
函数如何在任何地方工作-停止HTML5视频的方法是使用DOMNode.pause()
。 Maybe I misunderstood your post? 也许我误解了您的帖子?
Add an id to the video tag 向视频标签添加ID
than you can access the video DOM Object using Javascript 您将无法使用Javascript访问视频DOM对象
var videoControl = document.getElementById("myVideoPlayer"); var videoControl = document.getElementById(“ myVideoPlayer”); videoControl.pause();
videoControl.pause();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.