简体   繁体   English

光滑的滑块为每个幻灯片提供不同的自动播放

[英]Slick slider different autoplay for each slide

I have a slick carousel with both an image and a video, I have it so when it reaches the video it autoplays and when it finishes it goes to the image. 我有一个既有图像又有视频的圆滑传送带,我拥有它,因此当它到达视频时会自动播放,并在完成时转到图像。 What I would like is to have autoplay and autoplay speed only for the image and not for the slide with the video as when the video finishes it's waiting for the autoplay speed to finish and then move to the image which doesn't look right. 我想要的是仅对图像具有自动播放和自动播放的速度,而对于视频的幻灯片不具有自动播放和自动播放的速度,因为当视频结束时,它正在等待自动播放速度完成,然后移至看起来不正确的图像。 Is there a way to set the autoplay speed to 0 for the video slide...You can see the carousel in action here: http://foley13.webfactional.com/grid-website/carousel-test/ 有没有一种方法可以将视频幻灯片的自动播放速度设置为0 ...您可以在此处查看轮播的运行方式: http : //foley13.webfactional.com/grid-website/carousel-test/

Here is my javascript for the slider: 这是我的Javascript滑块:

jQuery(function($){
      var slider = $('.homeslider').slick({
        slidesToShow: 1,
        slidesToScroll: 1,
        arrows: false,
        fade: true,
        autoplay: true,
        autoplaySpeed: 1000,
        initialSlide: 1,
      });
      slider.on('afterChange', function(event, slick, currentSlide) {
        var vid = $(slick.$slides[currentSlide]).find('video');
        if (vid.length > 0) {
          slider.slick('slickPause');
          $(vid).get(0).play();
        }
      });

      $('video').on('ended', function() {
        console.log('Video Complete')
        slider.slick('slickPlay');
      });

    });


    /* Custom Next & Previous Links for Homepage slider */
    jQuery(function($) {
      $('.prev').click(function(){
        $('.homeslider').slick('slickPrev');
      })
    });

    jQuery(function($) {
      $('.next').click(function(){
        $('.homeslider').slick('slickNext');
      })
    });

Try to goto first slide when the video finished playing without waiting for the auto-play 视频播放完后,尝试转到第一张幻灯片,而无需等待自动播放

Try changing 尝试改变

$('video').on('ended', function() {
    console.log('Video Complete');
    slider.slick('slickPlay');
});

To this 对此

$('video').on('ended', function() {
    console.log('Video Complete');
    slider.slick('slickPlay');
    slider.slick('slickGoTo', 0);
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM