If the time was reached through the usual monotonic increase of the current playback position during normal playback, and if the user agent has not fired a timeupdate event at the element in the past 15 to 250ms and is not still running event handlers for such an event, then the user agent must queue a task to fire a simple event named timeupdate at the element. The rate at which the timeupdate event fires varies between browsers and as of today cannot be tuned for the level of precision you are looking for (Flash is still a bit ahead on this one). In HTML5 it is likely that the getCurrentTime() function and postMessage event in Youtube API are linked to the currentTime property and timeupdate event of the HTML5 media element specification. Time_update = (ytplayer.getCurrentTime()*1000) There maybe a small jump or non linearity in the time when you do this but if you poll the player at a high enough rate, this should be imperceptible. In that case I update my own timer with the new "actual" current time. On each iteration, I add 25 ms to the current time except in the case where I detect a change in the current time reported by the player. I run the function below on a timer with a 25 ms interval. However, if you apply some logic, you can detect when the player returns a new current time and update your own timer accordingly. If you poll it more frequently than that, it will return the same current time value on several consecutive polls. The player itself only updates the current time every 250 ms or so depending on the render engine and platform. I wrote a simple tween function that will poll the iFrame player at the frequency I desire and interpolate the time instants in between. I've come up with a workaround for my original problem. Has anybody successfully managed to get the iFrame player to report more accurate times and more frequently? Worse, the actual rate the message fires seems to be dependent on the render engine for the browser.ĭoes anybody know if it is possible to force the render engine to fire those messages more frequently so that greater time resolution can be achieved polling the player? I tried requestAnimationFrame and it doesn't solve the problem. Unfortunately this post message event is fired very infrequently - sometimes as low as 4 times a second. I did some research and it seems that because it's an iFrame, a postMessage is used to expose the players state to the player.getCurrentTime() call. We have now started to use the iFrame API which unfortunately does not allow anything near that level of accuracy. Using the flash API this was great because we could poll the player at 40ms intervals (25 FPS) and get very accurate current player time values. Our app needs to poll a YouTube video object using player.getCurrentTime() to drive some screen animations. I've been looking for a solution for this for a while now and I still haven't found it.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |