I'm not sure how reliable this method is, but something I found through
player.on("timeupdate", function(e) { console.log(player.currentTime) });
is that if the user smooths up to 0 times, the timeupdate event fires twice with currentTime==0 , and if the video loops fire, timeupdate 3 times with currentTime==0 . This is similar to FF, Chrome, IE, but I am wondering if this is related to the overall implementation of the specification or is hardware dependent. i.e. machine speed 3 ticks, slow machine 5 ticks currentTime==0
There is also player.played which will return a TimeRanges object of ranges. So:
player.on("timeupdate", function(e) { var tr = player.played; var hasLoopedOnce = (tr.end(tr.length-1)==player.duration); console.log(hasLoopedOnce); });
The problem is that after each iteration, the ranges wont reset, so this is only useful for detecting the first loop. I tried player.played = null, but to no avail.
But using these methods to set flags and combine with player.currentTime <=0 may be enough for some scenarios if just simply player.currentTime <=0 not enough.
source share