Re: Changing the 'timeupdate' callback to a higher frequency...

2,939 views
Skip to first unread message

Jonathan2

unread,
Oct 9, 2012, 3:08:09 AM10/9/12
to jpl...@googlegroups.com
I'm afraid it's a browser limitation; I looked into this in August and found several references you might find interesting (if not helpful!)

https://groups.google.com/d/msg/jplayer/mcZbuswy8ao/3L_OvzxmcWMJ

On Tuesday, 9 October 2012 03:15:44 UTC+1, Merk wrote:
The default ~250ms callback frequency of 'timeupdate' is not sufficient granularity for our needs. Is there a way to increase the frequency?
A 10ms interval would be optimal.

We have tried not hooking the timeupdate to a function and instead simply setting up:
  setInterval( function () { MyUpdate() }, 10);
...then accessing the player instance as $("#My_Player").data("jPlayer").status.currentTime; within the function.

Player access is successful. However, in using setInterval(), anything below a 250ms interval still seems to default to 250ms.

Any ideas on how to effectively increase the callback frequency?

Thanks!

Mark Panaghiston

unread,
Oct 12, 2012, 7:04:41 AM10/12/12
to jpl...@googlegroups.com
Yep, it is a browser limitation on the event frequency. The feeling was that 4 times a second is more than enough to update a time display in seconds and any faster is just wasting power. 4Hz is 2 times the Nyquist frequency for 1 second (1Hz) used for digital sampling. (So you're lucky it's not 500ms / 2Hz as that is all that is required.)

While I have never needed to do this, you can get a more accurate figure by accessing the HTML5 media element directly. jPlayer reads the media element info each time the timeupdate event occurs and puts it on the jPlayer status.

$("#My_Player").data("jPlayer").htmlElement.audio.currentTime

jPlayer uses an audio and a video element, so tweak that line as appropriate.

Since jPlayer might be using the Flash fallback, you need to check the HTML5 solution is being used.
$("#My_Player").data("jPlayer").html.used

I'm not sure how often the currentTime is updated on the media element, but it seems to change independent of timeupdate events.
Reply all
Reply to author
Forward
0 new messages