Reputation: 11
I'm using mediaelementjs library for a project.
HTML
<video width="640" height="360" id="player1" preload="none">
<source type="video/youtube" src="http://www.youtube.com/watch?v=nOEw9iiopwI" />
</video>
Javascript / jQuery
$('audio,video').mediaelementplayer({
loop: false,
features: ['playpause','progress','volume'],
success: function(player, node) {
$('#' + node.id + '-mode').html('mode: ' + player.pluginType);
console.log(player.duration);
}
});
but console.log(player.duration)
return always 0
So i think that maybe something wrong.
How can i get the video duration(in seconds) of video with mediaelementjs library?
Help me please.
Upvotes: 0
Views: 1265
Reputation: 25034
You are probably getting this because metadata of the media element is not yet loaded, checking after adding a event listener to that should solve the problem:
success: function(player, node) {
$('#' + node.id + '-mode').html('mode: ' + player.pluginType);
player.addEventListener('loadedmetadata', function(){
console.log(player.duration);
});
}
Upvotes: 2