// On slide change, pause all videos $('#main-slider').on('beforeChange', function(event, slick, currentSlide, nextSlide){ $('video').each(function() { $(this).get(0).pause(); }); }); // On slide chnage, play a video inside the current slide $('#main-slider').on('afterChange', function(event, slick, currentSlide, nextSlide){ if( $('.project-slide.slick-current').find('video').length !== 0) { $("#main-slider .slick-current video")[0].play(); } });
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter