JonathanL
JonathanL

Reputation: 176

How to know that an HTML Audio/Video element has ended while looping

I am trying to emit an event when a video has finished playing through one cycle while looping.

when I do this.nativeElement.addEventListener("ended", callsomething); the ended call is not made unless the video is stopped which will not happen as it is looping by default.

I attempted to use this.nativeElement.addEventListener("timeupdate", callsomething); where the "callsomething" function checked to see if it was at the end of the video but it never returned the exact end and so I ended up using it to check the beginning of the video since it always returned that. but then it turns out that when it is paused that will always be true...

Any suggestion on how I can know that the video has fully looped once?

Upvotes: 1

Views: 645

Answers (2)

JonathanL
JonathanL

Reputation: 176

I am removing the loop from the video and adding and '(ended)=endedFunc()' which will then play the video again effectively looping it while catching the end of video event.

Upvotes: 1

rudy0807
rudy0807

Reputation: 152

You can try with the following which is called at the end of the loop:

this.nativeElement.addEventListener("waiting", callsomething);

Upvotes: 2

Related Questions