Closing the mediaelement.js player after playing

The mediaelement.js is a great way to play video. They just have a bug at the end of a videos on internet explorer where the video stays full size, but the window shrinks. Looks a little like this:

MediaElement Close Fullscreen

Not so nice. So the way to fix it is to add a listener that exits full screen when the video is over:

$(function(){
$('audio,video').mediaelementplayer({
success: function(player, node) {
player.addEventListener('ended', function(e){
$('.mejs-unfullscreen button').click();
});
}
});
});

Leave a Reply