Video.js: 'timeupdate' event is really slow, fires ~ 500 - 250 ms

Created on 3 May 2017  路  5Comments  路  Source: videojs/video.js

Description

We switched from npm version 5.4.6 to 5.19.2 and the result is that the 'timeupdate' event fires with a much lower frequency.

Steps to reproduce

In the js file that instantiates the video player add the following:
1.

var self = this;
this.player = videojs('video-player');
this.currentTime = 0;

this.player.on('timeupdate', () => {
console.log(self.player.currentTime() - self.currentTime)
self.currentTime = self.player.currentTime();
});

Results

Expected

With the old version of vjs (5.4.6) we would see something like this:
mediaPlayer.js:166 0.2500309999999999
mediaPlayer.js:166 0.07432799999999995
mediaPlayer.js:166 0.180056
mediaPlayer.js:166 0.07106100000000026
mediaPlayer.js:166 0.17519200000000001
mediaPlayer.js:166 0.251023
mediaPlayer.js:166 0.07300099999999965
mediaPlayer.js:166 0.17660100000000067
mediaPlayer.js:166 0.07555599999999973
mediaPlayer.js:166 0.17385800000000007
mediaPlayer.js:166 0.24943500000000007
mediaPlayer.js:166 0.074357
mediaPlayer.js:166 0.1756909999999996
mediaPlayer.js:166 0.0754109999999999
mediaPlayer.js:166 0.1746300000000005

Actual

When using version 5.19.2 we get something like this:
mediaPlayer.js:166 0.500038
mediaPlayer.js:166 0.25145000000000006
mediaPlayer.js:166 0.49827699999999986
mediaPlayer.js:166 0.252907
mediaPlayer.js:166 0.4968060000000003
mediaPlayer.js:166 0.500178
mediaPlayer.js:166 0.2523409999999999
mediaPlayer.js:166 0.499196
mediaPlayer.js:166 0.49903699999999995
mediaPlayer.js:166 0.49927299999999963
mediaPlayer.js:166 0.250178
mediaPlayer.js:166 0.5002310000000003
mediaPlayer.js:166 0.2500549999999997
mediaPlayer.js:166 0.4998440000000004
mediaPlayer.js:166 0.25001099999999976
mediaPlayer.js:166 0.2502310000000003

Additional Information

videojs

updating from 5.4.6 -> 5.19.2

browsers

Chrome

OSes

OS

Most helpful comment

Yeah, you'll probably want to use requestAnimationFrame and check player.currentTime() inside of it.

All 5 comments

timeupdate is known to fire and fairly infrequent internals. If you're using flash, it should fire around 250ms, without flash, it'll be anywhere between 50ms to 250ms or even a bit more.
It's a bit weird that you're seeing a time difference between the two, though.
If you require precise timing information, you probably shouldn't rely on timeupdate.

@gkatsev what are the alternate equivalents to timeupdate if we need higher frequency callbacks?

@scheler what are you doing that requires higher frequency? But essentially you'll need to make your own time using requestAnimationFrame or setTimeout (depending on how precise you need to be).

@gkatsev I am trying to implement a loopBetween(start, end) which sometimes plays ~2-400ms beyond the end time which is sometimes not desirable for my usecase.

Yeah, you'll probably want to use requestAnimationFrame and check player.currentTime() inside of it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

d3x7r0 picture d3x7r0  路  4Comments

zhulduz picture zhulduz  路  3Comments

jeonghwaYoo picture jeonghwaYoo  路  3Comments

stephanedemotte picture stephanedemotte  路  4Comments

borm picture borm  路  3Comments