Reputation: 9476
I have html code like below
<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>
First time i am creating video tag and appending to main div but from next onwards i am just playing video using display show hide but I want to get duration of video everytime but below code is calling once only.
this.addEventListener('loadeddata', function(e) {
e.target.duration
});
Upvotes: 0
Views: 1084
Reputation: 8204
In pure JavaScript it is not easy because by definition, .loadeddata
runs once in the User Agent...
Since I can see you have "jQuery
-tagged" your question, I may suggest you use this piece of code
var video = $('#videoID')[0];
video.onloaddata = function(e) { /* your code here*/ };
Voilà!
Upvotes: 1