var myPlayer = new MediaElementPlayer('.player_1', {
success: function (mediaElement) {
// properties need to refer the MEJS underlaying element
console.log(mediaElement.paused); // return true
console.log(mediaElement.muted); // returns false
// same for events
mediaElement.addEventListener('playing', function () {
console.log("event triggered after play method");
}, false);
mediaElement.addEventListener('pause', function () {
// set time at 90 seconds and unmute if player is paused
// but wait 3 seconds before doing that
// notice the previous time set (145 seconds)
setTimeout(function () {
// setters can refer MEJS underlaying element
mediaElement.setCurrentTime(90);
mediaElement.setMuted(false);
}, 3000);
}, false);
}
});
// methods can refer the MEJS player
myPlayer.play();
// but not properties
console.log("paused? " + myPlayer.paused); // returns undefined
console.log("muted? " + myPlayer.muted); // returns undefined
// pauses, set time and mute after 5 seconds of playing
setTimeout(function () {
myPlayer.pause(); // method
// setters can also refer the MEJS player
myPlayer.setCurrentTime(145);
myPlayer.setMuted(true);
}, 5000);
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.