webamp icon indicating copy to clipboard operation
webamp copied to clipboard

Timeupdate event is not fired consistently

Open durasj opened this issue 7 years ago • 2 comments

I noticed this some time ago when opening the #498.

Sometimes it gets fired after roughly 250ms and sometimes after roughly 500ms. This means the Time doesn't get updated precisely every 1 second - and with it also the seeking bar. E.g. timeElapsed is set to 3.0, 3.5, 3.75, 4.25 (so it's late 250ms - took 1.25s to change from 3), 4.75, 5.0 (so it's early 250ms - took 0.75s to change from 4). This means it doesn't look very smooth.

The question would be how to replace it. Maybe it would make sense to setInterval(dispatch UPDATE_TIME_ELAPSED media.timeElapsed(), 250) when playing and clear it on stop. What I don't like is that it doesn't have to happen at the beginning of the frame. Meaning if it gets fired at the end of a frame, we may delay it. On the other hand, I can't imagine how requestAnimationFrame could be used.

durasj avatar Aug 16 '18 11:08 durasj

Ah, I had noticed this as well, but didn't understand the underlying reason.

What do you mean by

Meaning if it gets fired at the end of a frame, we may delay it.

Do you mean the stack frame or the audio frame?

captbaritone avatar Aug 18 '18 17:08 captbaritone

Oh, I was actually thinking about a situation when the browser will be pushing 60fps during some motion and event will be fired at the end of the frame causing it to skipped. But it shouldn't be any worse than timeupdate event. I honestly don't like intervals way too much but I don't think there is a better way.

What do you please think?

durasj avatar Aug 18 '18 21:08 durasj