5 videos released

I am trying to listen to the "completed" video from an HTML 5 tag. It seems that it was very fired during testing. In most cases, it does not go at all. I encoded my .mov to mp4 using Adobe Midea Encoder.

Does anyone know why it doesn’t work, and should I encode my files externally on a media encoder for best results.

This is how I listen to the finished even (Nel is a video element;):

el.addEventListener("ended", this.endHandler); 

This is basic HTML code using:

 <video id="v1"></video> 

I am dynamically setting up src video with code. He plays great, sometimes I get a completed event, but not always.

thanks

0
source share
1 answer

It seems that the video sometimes stops playing shortly before the actual time. Something like 0.0000025 seconds earlier, which means the completed event has not been dispatched.

To fix this, round the duration and check the current time on setInterval.

 //duration = 5.26 ( rounded down from 5.2600041) if(this.video.currentTime >= this.duration) { //VIDEO ENDED } 
0
source

Source: https://habr.com/ru/post/886352/


All Articles