I would like to loop my Mediaelement.js video only 5 times. I've found the setting where you can set loop: true
, which makes you video loop. But with this setting, it loops infinitely. I would like to stop the loop after 5 times.
$(this).mediaelementplayer({
loop: true,
alwaysShowControls: false,
startVolume: 0,
features: [],
});
Does the Mediaelement have some extra settings to limit this loops? Or should I do this by using custom Javascript?
there is an event that fire when the video ends, you could use it to know how many time the vid played and stop it at five, this code is not tested, but should point you in the right direction
var player = $('videoContainer').mediaelementplayer();
var playCount = 0;
player.media.addEventListener('ended', function(e) {
playCount++;
if (playCount>=5){
player.stop();
}
}, false);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With