Reputation: 81
Im trying to listen to the video 'ended' event from the HTML 5 video tag. It seems to be fired very imtermitently during testing. Most times it doesnt get sent at all. I have encoded my .mov to an mp4 with Adobe Midea Encoder.
Does anybody know why it might not be working and should I be encoding my files outside on media encoder for better results.
This is how im listening to the ended even (Nel is the video element;):
el.addEventListener("ended", this.endHandler);
This is the basic HTML im using:
<video id="v1"></video>
Im setting the video src dynamically with code. It plays fine, sometimes I get the ended event but not always.
Thanks
Upvotes: 0
Views: 784
Reputation: 81
It seems a video sometimes stops playing just before the actual duration time. Something like 0.0000025 secs before, which means the ended event isnt sent.
To fix this im rounding the duration and checking the current time on a setInterval.
//duration = 5.26 ( rounded down from 5.2600041)
if(this.video.currentTime >= this.duration) {
//VIDEO ENDED
}
Upvotes: 3