Created
October 21, 2020 10:05
-
-
Save harmandeep-singh/e40855a0a2e55f3c6c68d153ec30404a to your computer and use it in GitHub Desktop.
FlexSlider AutoPlay On Video End
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
$('.flexslider').flexslider({ | |
animation: "slide", | |
slideshow: false, // Stop Auto Slide Changes | |
directionNav: false, | |
start: function() { | |
updateTimeVideoTimeAction(); | |
}, // Fires when the slider loads the first slide | |
before: function() { | |
// Stop all Video if any Playback left | |
$('.slides video').each(function() { | |
$(this).get(0).pause(); | |
$(this).get(0).currentTime = 0; | |
}); | |
}, // Fires asynchronously with each slider animation | |
after: function() { | |
updateTimeVideoTimeAction(); | |
}, // Fires after each slider animation completes | |
}); | |
}); | |
function updateTimeVideoTimeAction() { | |
$('.flexslider').flexslider("pause"); | |
var video = $(".flex-active-slide video").get(0); | |
video.play(); | |
video.addEventListener('timeupdate', (event) => { | |
if (video.ended == true) { | |
$('.flexslider').flexslider("next"); | |
} | |
}); | |
} | |
/* <!-- HTML --> | |
<div id="main-slider" class="flexslider"> | |
<ul class="slides"> | |
<li class="active"> | |
<video autoplay muted> | |
<source src="first-video.mp4" type="video/mp4" /> | |
</video> | |
</li> | |
<li> | |
<video muted> | |
<source src="second-video.mp4" type="video/mp4" /> | |
</video> | |
</li> | |
</ul> | |
</div> | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment