使用播放器隐藏div时停止JWPlayer [英] Stop JWPlayer when hidden the div with the player
问题描述
我有一个网站,我使用JavaScript来添加或删除css类。使用这种方法我隐藏div或显示div,因为我需要它。它的效果非常好。
I have a site where I'm using a JavaScript to add or remove a css class. Using this method I hide a div or show a div, as I need it. It works great.
问题是当我隐藏窗口或更好地说,div时,一个div用JWplayer打开一个视频。声音仍在播放,所以当有人点击隐藏按钮或关闭按钮时,我需要一个代码来停止视频。
The problem is one div opens a Video with a JWplayer, when I hide the "window" or better say, the div. The sound is still playing, so I need a code to put stop on the video when someone clicks the "hide" button or close button.
你是怎么做到的?我不知道。
How do you do that? I have no idea.
谢谢
HTML
<div class="videoquon">
<div class='my-video-close'></div>
<div id='my-video'></div>
<script type='text/javascript'>
jwplayer('my-video').setup({
file: 'qvideo.f4v',
width: '600',
height: '337'
});
</script>
</div>
JavaScript
JavaScript
$('div.vidreveal a').click(
function(event) {
event.stopPropagation();
$('div.videoquon').slideToggle(300);
}
);
$('div.my-video-close').click(
function(event) {
event.stopPropagation();
$('div.videoquon').slideToggle(300);
}
);
推荐答案
我不知道JW Player,但是判断他们的文档,我将继续
I don't know JW Player, but judging by their docs, I'm going to go with
$( 'div.my-video-close' ).click( function( event ) {
event.stopPropagation();
jwplayer( 'my-video' ).stop();
$( 'div.videoquon' ).slideToggle( 300 );
});
...或 jwplayer('my-video')。pause( );
取决于所需的效果。
...or jwplayer( 'my-video' ).pause();
depending on the desired effect.
这篇关于使用播放器隐藏div时停止JWPlayer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!