HTML5视频停止onClose [英] HTML5 Video Stop onClose

查看:117
本文介绍了HTML5视频停止onClose的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery工具进行叠加。在叠加层中,我有一个HTML5视频。但是,当我关闭叠加层时,视频会继续播放。任何想法当我关闭覆盖层时,我可能如何让视频停止?这里是我的代码:

  $(img [rel])。overlay({onClose:function(){< ;以某种方式停止视频>},遮罩:{color:'#000',opacity:0.7}}); 

我尝试使用

  $( '视频')暂停(); 

但是,这也暂停了叠加。

这个问题可能与您选择的
$(video)不是选择器


正确的选择器可能会为视频标签添加 id 元素,即

让我们说你的视频元素看起来像这样:

 < video id =vid1width =480height =267 oster =example.jpgdurationHint =33> 
< source src =video1.ogv/>
< source src =video2.ogv/>
< / video>

然后你可以通过 $(#vid1)来选择它。 code>带有散列标记(#),jquery中的id选择器。
如果一个视频元素在函数中被暴露,那么你可以访问 HtmlVideoElement (HtmlMediaElement)。这个元素控制视频元素,在你的情况下你可以使用为视频元素添加pause()方法。



检查VideoElement的参考此处

同时检查是否有回退参考这里


I'm using jQuery tools for an overlay. Inside the overlay I have an HTML5 video. However, when I close the overlay, the video keeps playing. Any idea how I might get the video to stop when I close the overlay? Here's the code I have:

$("img[rel]").overlay({ onClose: function() { <stop the video somehow> }, mask: { color: '#000', opacity: 0.7 }});

I tried using

$('video').pause();

But this paused the overlay as well.

解决方案

The problem may be with jquery selector you've chosen $("video") is not a selector

The right selector may be putting an id element for video tag i.e.
Let's say your video element looks like this:

<video id="vid1" width="480" height="267" oster="example.jpg" durationHint="33"> 
    <source src="video1.ogv" /> 
    <source src="video2.ogv" /> 
</video> 

Then you can select it via $("#vid1") with hash mark (#), id selector in jquery. If a video element is exposed in function,then you have access to HtmlVideoElement (HtmlMediaElement).This elements has control over video element,in your case you can use pause() method for your video element.

Check reference for VideoElement here.
Also check that there is a fallback reference here.

这篇关于HTML5视频停止onClose的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆