Video.js currentTime () is incorrect until the timeupdate event fires

I noticed a little inconsistency, which I hope to check either as the quirk of HTML5, or something special for Video.js .

It seems that if you call the Video.js' currentTime() function, providing a new time, any further calls to currentTime() (to get the current time) will not return the correct time (it will return the previous time) until the timeupdate event timeupdate . After the timeupdate event timeupdate currentTime() will return the correct time.

For example, if the video has not started yet, but Video.js has loaded together with all the metafiles, etc.:

 videoPlayer.addEvent('timeupdate', function() { console.log('Event callback: ' + player.currentTime); }); console.log('Original time: ' + player.currentTime); player.currentTime(100); console.log('New time: ' + player.currentTime); 

The result that I expected would look like this:

 Original time: 0 New time: 100 Event callback: 100 

However, I get the following:

 Original time: 0 New time: 0 Event callback: 100 

Any insight would be fantastic!

Edit: I can reproduce this in Chrome and Safari on OSX, but not on Firefox on OSX (all using HTML5). I can also reproduce this on IE8 using Flash Player and IE9 using HTML5 player.

+6
source share
1 answer

I have seen similar behavior on several other html5 / flash players.

I have always been on the assumption that even after searching through currentTime(100); , playhead will not be updated until the next timeupdate event.

+2
source

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


All Articles