禁用单击视频轮播中的播放按钮

时间:2015-02-09 15:07:10

标签: jquery owl-carousel

![在此输入图像说明] [1]此刻我可以点击转盘中的任何视频,它将出现在iframe中,我只是拍摄视频的src。我想知道是否有办法停止允许用户播放视频时播放视频,但仅在视频位于iframe内时播放。

<div class="row">
<div class="main">
    <iframe width="600" height="480" id="mainvideo" src="https://www.youtube.com/embed/DU6UV2GPzIk?" style="margin: 30px auto 10px;float: none;display: block;" src="" frameBorder="0" allowfullscreen=""></iframe>

    <div id="owl-demo" class="owl-carousel">

        <div class="article-video red" data-merge="2"><a class="owl-video" href="https://www.youtube.com/embed/DU6UV2GPzIk?"></a></div>
        <div class="article-video" data-merge="2"><a class="owl-video" href="https://www.youtube.com/embed/2ZfqGr7HbEo?"></a></div>
        <div class="article-video" data-merge="2"><a class="owl-video" href="https://www.youtube.com/embed/053yP1wQR_s?"></a></div>
        <div class="article-video" data-merge="2"><a class="owl-video" href="https://www.youtube.com/embed/B-QIFAy6LPI?"></a></div>
        <div class="article-video" data-merge="2"><a class="owl-video" href="https://www.youtube.com/embed/4_ZRUC0g1ic?"></a></div>
        <div class="article-video" data-merge="2"><a class="owl-video" href="https://www.youtube.com/embed/YU6AU-khKuo?"></a></div>
        <div class="article-video" data-merge="2"><a class="owl-video" href="https://www.youtube.com/embed/Bkz5wyb_6j8?"></a></div>
        <div class="article-video" data-merge="2"><a class="owl-video" href="https://www.youtube.com/embed/f1kx4Bce6nI?"></a></div>
        <div class="article-video" data-merge="2"><a class="owl-video" href="https://www.youtube.com/embed/1HTq4F_js2g?"></a></div>

    </div>
</div>

这是我用来更改IFrame视频的Jquery代码。

   $(document).ready(function(){
    $(".article-video").click(function(e) {
        e.preventDefault();
        var href= $(this).find('a').attr('href');
        var target = $('.article-video').index($(this));
        $("#mainvideo").attr("src", href);

    })
});

&#13;
&#13;
$(document).ready(function() {

        var owl = $('.owl-carousel');
        owl.owlCarousel({
            items:4,
            margin:20,
            loop:true,
            video:true,
            lazyLoad:true,
            dots:false,
            responsive:{
                0:{
                    items:1
                },

                678:{
                    items:3
                },
                1000:{
                    items:4
                }
            },
            nav:true,
            navText: [
                "<i class='icon-chevron-left icon-white'><</i>",
                "<i class='icon-chevron-right icon-white'>></i>"
            ]

        });
    });

$(document).ready(function(){
        $(".article-video").click(function(e) {
            e.preventDefault();
            var href= $(this).find('a').attr('href');
            var target = $('.article-video').index($(this));
            $("#mainvideo").attr("src", href);

        })
    });
&#13;
    <link rel="stylesheet" href="http://www.jackpotjoy.com/promo/responsive_templates/Test/assets/css/demo.css">
    <link rel="stylesheet" href="http://www.jackpotjoy.com/promo/responsive_templates/Test/owlcarousel/owl.carousel.css">
    <link rel="stylesheet" href="http://www.jackpotjoy.com/promo/responsive_templates/Test/owlcarousel/owl.theme.css">

<div class="row">
    <div class="main">
        <iframe width="600" height="480" id="mainvideo" src="https://www.youtube.com/embed/DU6UV2GPzIk?" style="margin: 30px auto 10px;float: none;display: block;" src="" frameBorder="0" allowfullscreen=""></iframe>

        <div id="owl-demo" class="owl-carousel">

            <div class="article-video red" data-merge="2"><a class="owl-video" href="https://www.youtube.com/embed/DU6UV2GPzIk?controls=0"></a></div>
            <div class="article-video" data-merge="2"><a class="owl-video" href="https://www.youtube.com/embed/2ZfqGr7HbEo?controls=0"></a></div>
            <div class="article-video" data-merge="2"><a class="owl-video" href="https://www.youtube.com/embed/053yP1wQR_s?controls=0"></a></div>
            <div class="article-video" data-merge="2"><a class="owl-video" href="https://www.youtube.com/embed/B-QIFAy6LPI?controls=0"></a></div>
            <div class="article-video" data-merge="2"><a class="owl-video" href="https://www.youtube.com/embed/4_ZRUC0g1ic?"></a></div>
            <div class="article-video" data-merge="2"><a class="owl-video" href="https://www.youtube.com/embed/YU6AU-khKuo?"></a></div>
            <div class="article-video" data-merge="2"><a class="owl-video" href="https://www.youtube.com/embed/Bkz5wyb_6j8?"></a></div>
            <div class="article-video" data-merge="2"><a class="owl-video" href="https://www.youtube.com/embed/f1kx4Bce6nI?"></a></div>
            <div class="article-video" data-merge="2"><a class="owl-video" href="https://www.youtube.com/embed/1HTq4F_js2g?"></a></div>

        </div>
    </div>
</div>


<script src="http://www.jackpotjoy.com/promo/responsive_templates/Test/assets/js/jquery-1.11.0.min.js"></script>
<script src="http://www.jackpotjoy.com/promo/responsive_templates/Test/owlcarousel/owl.carousel.js"></script>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

试试这个!

$('.owl-video-play-icon').remove();

jsfiddle here:http://jsfiddle.net/lharby/31muLtex/4/

(我尝试在.owl-video-play-icon上禁用点击事件,但它没有工作,可能是因为youtube js稍后被解雇,它确实意味着可能有另一个解决方案,但这确实会阻止视频在缩略图中播放)。