使用Video.js暂停jQuery Cycle [英] Pause jQuery Cycle with Video.js

查看:234
本文介绍了使用Video.js暂停jQuery Cycle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个jquery循环滑块,我需要在播放视频时或者当到达显示视频的幻灯片时暂停 。 (这些选项中的任何一个都没问题,但我无法弄清楚如何暂停具有特定类或ID的幻灯片。)我正在使用 video.js 显示视频。

I have a jquery cycle slider that I need to pause either when a video is played or when a slide is reached that displays a video. (Either of those options is fine, but I could not figure out how to pause a slide with a certain class or id.) I am using video.js to display videos.

当我按下播放时视频开始播放,但当我将鼠标从视频中移开时,它会自动播放转到下一张幻灯片。如果我点击寻呼机缩略图它会暂停,但如果幻灯片正常进行并按下播放,它将遵循周期'超时'设置的规则。

What is happening is when I press play the video starts playing, but when I move the mouse off the video it automatically goes to the next slide. If I click on the pager thumbnail it stays paused, but if the slideshow progresses normally and I press play, it follows the rules set by the cycle 'timeout.'

什么我正在寻找一种在播放视频时暂停幻灯片放映的方法 - 通过在视频开始播放时调用事件,或者在到达视频幻灯片时完全暂停幻灯片放映。

What I am looking for is a way to pause the slideshow when the video is played - either by calling an event when the video starts playing, or by pausing the slideshow entirely when a video slide is reached.

我头脑中有这个:

<script>
    jQuery(document).ready(function($) {    
        $(".project_slides").cycle({
        fx:'fade',
            timeout: 5000,
            prev : '#prev',
            next : '#next',
            pager : '#pager',
            pause: 1,
            pagerAnchorBuilder: function(idx, slide) {
                return '#pager li:eq(' + (idx) + ') a';
            }
        });

        $('#pager a').click(function() { 
            $('.project_slides').cycle('pause'); 
        });

        function pauseitall() {
            $('.project_slides').cycle('pause');
        }   
    });

</script>

并且在正文中:

<div class="project_slides">
    <div class="slide">
        <img src="/media/{{ Slide.media }}" alt="{{ Slide.caption }}" />
    </div>

    <div class="slide">
        <video id="video_11" 
            class="video-js vjs-default-skin" 
            controls width="512" 
            height="406" 
            poster="/media/images/video-poster.png" 
            preload="auto" loop>
            <source type="video/mp4" src="/media/{{ Slide.media }}">
        </video>

        <script>
            $(function() {
                _V_("video_11").ready(function() {
                var myPlayer = this;
                addEvent(myPlayer.video, "play", function () {
                    pauseitall()}, false);
                    myPlayer.play();
                });
            });
        </script>
    </div>
</div>

显然,pauseitall()函数没有被正确调用,但我一直在为此努力这么久(在如此多的迭代中)我最终只是想在这里发布它,看看是否有人知道解决方案。

Obviously the pauseitall() function is not being called properly, but I've been struggling with this for so long (in so many iterations) that I finally just wanted to post it here and see if anyone knows a solution.

供参考,使用jQuery 1.7.2,jquery循环2.9999.5,和Video.js 3.2.0

For reference, using jQuery 1.7.2, jquery cycle 2.9999.5, and Video.js 3.2.0

推荐答案

试试这个:

myPlayer.addEvent("play", pauseitall);

这就是文档如何指定如何绑定到事件

this is how the docs specify how to bind to events

这篇关于使用Video.js暂停jQuery Cycle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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