It may just be a necessary price to pay for the advantages of having a more overall flexible solution...but interestingly the chrome and FF native HTML5 video players seem to manage without the brief pause...
Unfortunately, that is the way the built-in “repeat” option works. It’s less of a “looping” feature and more of a “I just want the video to play again” option.
The first function finds out the duration of the content. The second function listens to an .on(“time”) event that returns the position of playback a few times per second. Then the position of playback reaches less than one second before the end of the video, it makes the player seek back to the beginning of the video.
Hopefully, you’ll have some luck with this.
Please let me know if you need any more help or have any other questions.
The only information that .getDuration returns is the duration of the content, in seconds. If the content is a live stream, it will return a value of “-1”. The .on(“play”) event fires when the player enters a “playing” state, so it may possibly be before the video starts playing for the viewer, so that’s why I have it setup to timeout for a second before it actually returns the duration.
The issue with this method of looping, however, is that browsers are not consistent with how often they fire the *.on(“time”) event, so if you loop the content enough times, it’s possible for the position of the video to match the duration, and so the playback stops. However, there is no real workaround for this. It all depends on whatever content you are showing, if it ends on a black screen, you may be able to increase the amount of time before the end of the video that the player goes back to the beginning.
I hope that makes sense!
This question has received the maximum number of answers.