According to what is stated on mediaelement.js website it should be easy to get player state. But I cannot figure out how to do it.
I'm creating player like this and trying to read properties (the player itself is working without problems).
var player = new MediaElementPlayer('.player_1')
player.play();
player.pause();
log(player.paused);
log(player.volume);
But this fails - both paused
and volume
are undefined
.
I'm using latest 2.8.2 version.
jsfiddle example: http://jsfiddle.net/chodorowicz/wLu2v/3/
OK, John Dyer answered me on the Github support page: https://github.com/johndyer/mediaelement/issues/497
It's needed to get mediaelement itself media
new MediaElementPlayer('.player_1', {success: function(media, node, player) {
// this will be undefined since it's the player with buttons
alert(player.paused);
// this will be a real value since it's the underlying mediaelement
alert(media.paused);
}
});
To get media element later you can use following code
$('player')[0].player.media;
来源:https://stackoverflow.com/questions/10689533/how-do-i-get-mediaelement-js-player-state-paused-volume-etc