Pause mediaelement.js using jquery
11,153
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.
Comments
-
evolutionxbox about 2 years
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.
-
Manu almost 10 yearsImportant note: this only works if you explicitly create the
player
object using thevar player = new MediaElementPlayer(...
method. -
Manu almost 10 yearsOne important detail: for the
play()
andpause()
methods to work, you need to create the player object explicitly by using thevar player = new MediaElementPlayer()
method, as described at mediaelementjs.com. If you do that, even a simpleplayer.pause()
will do the trick.