I'm wondering how to stop all the MediaElement players currently in the DOM. I've tried this:
$('video,audio').each(function() {
$(this)[0].player.pause();
});
Let me know if that works.
A quick and dirty one, but neither work.
$(".mejs-play").live('click',function(){
$(".mejs-pause").trigger('click');
});
Tried to do my homework on this one but can't seem to find a response anymore.
Try this...
$('video, audio').each(function() {
$(this)[0].pause();
});
Here's a simple way to do a "stop all".
When first creating your MediaElement players, create them each explicity (as opposed to using $('video,audio').mediaelementplayer()
):
var mediaElementPlayers = [];
$('video,audio').each(function(){
mediaElementPlayers.push(new MediaElementPlayer(this));
});
And then, when you want to stop them:
for (var i=0; i<mediaElementPlayers.length; i++){
mediaElementPlayers[i].pause(); // pause
if (mediaElementPlayers[i].getCurrentTime()){
mediaElementPlayers[i].setCurrentTime(0); // rewind
}
}
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