[英]Trying to interpret jQuery again - how do I pause on video play?
Ok, I'm trying to modify some already written jQuery - as background, I know Javascript decently, but I'm only so-so with jQuery. 好的,我正在尝试修改一些已经编写好的jQuery-作为背景,我对Java相当了解,但是我对jQuery只是这样。 My understanding of this code is that there's a scrolling bar, which will change every 6 seconds. 我对这段代码的理解是,有一个滚动条,它将每6秒更改一次。 I am unsure if there's any video specific code in here though - right now the scrollbar has a video embedded on one of the panes, which is clicked on. 我不确定这里是否有任何特定于视频的代码-现在,滚动条在其中一个窗格中嵌入了一个视频,然后单击该窗格。
What I am trying to do, is set up an image (currently inside <div class=vid>
, not shown), which when it is clicked, will stop the paning, UNTIL one of the buttons at the bottom is clicked, and it will also play a flash video. 我想做的是设置一个图像(当前在<div class=vid>
,未显示),单击该图像将停止平移,直到单击底部的一个按钮,然后单击它还将播放Flash视频。
Here's the code: 这是代码:
<script type="text/javascript">
jQuery(document).ready(function() {
var scroll_item = jQuery("#chained").scrollable({circular: true, mousewheel: false}).navigator().autoscroll({
interval: 6000,
autoplay: false,
autopause: false
});
window.scroll_control = scroll_item.data("scrollable");
scroll_control.play();
var $playBtn = $('#p-p-btn');
$playBtn.click(function(){
if($(this).hasClass('play')){
$(this).addClass('pause');
$(this).removeClass('play');
scroll_control.play();
} else if($(this).hasClass('pause')) {
$(this).addClass('play');
$(this).removeClass('pause');
scroll_control.stop();
};
});
jQuery('#chained').hover(
function() { scroll_control.stop(); },
function() {
if ($playBtn.hasClass('pause')) {
scroll_control.play();
}
}
);
});
</script>
I believe all I have to do is add a condition which will determine if the image has been clicked (it is in <div class=vid>
, but I am going to give it an id as well probably), which will turn the paning off (perhaps by "clicking" the play/off button?), and it will also launch the video with an auto play setting. 我相信我所要做的就是添加一个条件,该条件将确定是否单击了图像(它在<div class=vid>
,但我也可能为其指定一个ID),这将使平移关闭(可能是通过“单击”播放/关闭按钮?),它还将以自动播放设置启动视频。
Does that sound accurate? 听起来准确吗?
How would I turn the paning off? 我该如何关闭平移?
I don't fully understand the code, because i don't know the whole context. 我不完全了解代码,因为我不了解整个上下文。 But try to add this in your document ready: 但是,请尝试将其添加到文档中:
$("#YOURIMAGEID").bind("click",function(){
scroll_control.stop();
$('#p-p-btn').addClass('play');
$('#p-p-btn').removeClass('pause');
//other logic
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.