Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save harmandeep-singh/e40855a0a2e55f3c6c68d153ec30404a to your computer and use it in GitHub Desktop.
Save harmandeep-singh/e40855a0a2e55f3c6c68d153ec30404a to your computer and use it in GitHub Desktop.
FlexSlider AutoPlay On Video End
$(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