I'm using slick slider to create a hero block, I have a vimeo video and an image that I want to auto slide, I have this working fine. What I'm wanting to achieve is that when the slide gets to the vimeo video the slider stops the autoplay until the video has finished playing and then start the autoplaying of the slides again.
This is my basic html for the slider:
<div id="main-image" class="sliderMain">
<div>
<iframe id="video" class="embed-player slide-media" src="https://player.vimeo.com/video/273725261?api=1&byline=0&portrait=0&title=0&background=1&mute=1&loop=0&autoplay=1&id=273725261" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
<div>
<img src="http://foley13.webfactional.com/grid-website/wp-content/uploads/2018/06/o-FRIENDS-facebook.jpeg">
</div>
</div>
This is my Javascript to get the slider working:
$('.sliderMain').on('afterChange', function(event, slick, currentSlide) {
var vid = $(slick.$slides[currentSlide]).find('oembed');
if (vid.length > 0) {
$('.sliderMain').slick('slickPause');
$(vid).get(0).play();
}
});
$('oembed').on('ended',function(){
console.log('Video Complete')
$('.sliderMain').slick('slickPlay');
});
$(document).ready(function(){
$('.sliderMain').slick({
slidesToShow: 1,
slidesToScroll: 1,
arrows: true,
fade: true,
autoplay: true,
autoplaySpeed: 1000
});
});
I've added afterChange functions which work but the slick slider autoplay speed is making it look like it doesn't so the video slide is sliding before the video has finished playing. You can see the example here: http://foley13.webfactional.com/grid-website/