jeudi 2 avril 2015

How to get duration from HTML5 Multiple video?

I have multiple video tags in single screen with absolute position and want to get that longer video from multiple and when longer video ends want to execute code.



<div id="#p0">
<div style="width:1320px;height:1080px;position:absolute;left:0px;top:0px;z-index:0;">
<video preload="auto" autoplay>
<source src="1.mp4" type="video/mp4">
<source src="1.ogv" type="video/ogg">
</video>
</div>
<div style="width:600px;height:1080px;position:absolute;left:1321px;top:0px;z-index:0;">
<video preload="auto" autoplay>
<source src="2.mp4" type="video/mp4">
<source src="2.ogv" type="video/ogg">
</video>
</div>
<div style="width:1000px;height:600px;position:absolute;left:200px;top:200px;z-index:5;">
<video preload="auto" autoplay>
<source src="3.mp4" type="video/mp4">
<source src="3.ogv" type="video/ogg">
</video>
</div>
</div>


and i have tried below code but getting NaN when log duration



$('#p0 div video').each(function() {
console.log($(this));
alert($(this).duration);console.log("dur "+$(this).duration);
if (longestVid == "" || longestVid.duration < $(this).duration)
longestVid = this;
});


How can i get duration?


Aucun commentaire:

Enregistrer un commentaire