Javascript 如何在模型关闭时暂停视频(videojs)
我所拥有的:Javascript 如何在模型关闭时暂停视频(videojs),javascript,jquery,html5-video,video.js,Javascript,Jquery,Html5 Video,Video.js,我所拥有的: <script> function stopvideos() { $(".video-js")[0].player.pause(); //$("#example_video_0").pause(); //$("#example_video_0").get(0).pause(); //jQuery(".video-js")[0].player.pause(); //$("#example_video_0").trigger("p
<script>
function stopvideos()
{
$(".video-js")[0].player.pause();
//$("#example_video_0").pause();
//$("#example_video_0").get(0).pause();
//jQuery(".video-js")[0].player.pause();
//$("#example_video_0").trigger("pause");
//$("#example_video_0").player.pause();
// $('#example_video_1').remove();
/*VideoJS.DOMReady(function(){
var myPlayer = VideoJS.setup("example_video_0");
myPlayer.pause();
});
*/
}
</script>
<div id="animation-reel">
<a class="bClose" onclick="stopvideos();">x<a/>
<video id="example_video_0" class="video-js vjs-default-skin" controls preload="none" width="210" height="118"
poster="videos/video-js_poster.jpg"
data-setup="{}">
<source src="videos/animation.m4v" type='video/mp4' />
<!--<source src="peo_v10.webm" type='video/webm' />
<source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg' />
<track kind="captions" src="videos/captions.vtt" srclang="en" label="English" />-->
</video>
</div>
我想要的是:
暂停视频单击模型关闭链接x
提前感谢请参考此工作示例 只需通过以下方式访问视频元素
var vid = document.getElementById("example_video_0");
vid.pause();
享受 只需删除iframe的src,它将在模型关闭后停止播放视频
$('button.close').click(function(){
$('iframe').attr('src','');;
});
你能分享你的代码来测试吗?你试过小提琴的例子吗?朋友好,它在小提琴上运行得很好,但当我复制整个代码,制作一个html文件并在浏览器上运行时,它就不工作了。
$('button.close').click(function(){
$('iframe').attr('src','');;
});