Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pause mediaelement.js using jquery

I have initialised the element using:

$('video').mediaelementplayer();

Now I would like to target that video and pause it when a link is pressed:

$('.page_button').live('click', function() {
    $('video').pause();
});

Thanks.

like image 839
evolutionxbox Avatar asked Oct 11 '11 16:10

evolutionxbox


1 Answers

Each element with a media player element has a player property defined. This is where all the methods reside. You can access it with either of the following methods:

$('video')[0].player.pause(); // Be sure the video element exists.

$('video').each(function(){this.player.pause()}) // Safe.
like image 182
Brian Nickel Avatar answered Oct 13 '22 00:10

Brian Nickel