[whatwg] Video Element Events? - Use Case: Custom Progress Bar
jonas at sicking.cc
Fri Oct 31 18:09:33 PDT 2008
Eric Carlson wrote:
> Ian -
> On Oct 28, 2008, at 10:36 PM, Chris Double wrote:
>> On Wed, Oct 29, 2008 at 5:22 PM, Charles Iliya Krempeaux
>> <supercanadian at gmail.com> wrote:
>>> Perhaps I didn't read the spec carefully enough, but I don't see any
>> You're looking for the 'timeupdate' event. This gets raised whenever
>> the current playback position changes. From the spec section 188.8.131.52:
>> "If the time was reached through the usual monotonic increase of the
>> playback position during normal playback, the user agent must then
>> queue a task
>> to fire a simple event called timeupdate at the element. (In the other
>> such as explicit seeks, relevant events get fired as part of the overall
>> process of changing the current playback position.)"
>> Although this is hidden away in the cue ranges section, it happens on
>> normal playback without cue ranges.
> I think requiring a user agent to post events as a movie plays is a
> mistake. It will mean that *every* page will incur the overhead, even if
> no scripts are listening for the events.
> I understand that some pages will need to keep scripted UI in sync
> document.addEventListener('play', updateTimeDisplay, true);
> document.addEventListener('pause', updateTimeDisplay, true);
> function updateTimeDisplay()
> var vid = document.getElementById('video');
> if (!vid.paused && !vid.ended && vid.networkState >
> setTimeout(updateTimeDisplay, 200);
> // update display here
> Using a timer also allows a script to update at exactly the frequency
> they need instead of at whatever frequency the UA happens to post events.
> Video and audio playback is already extremely CPU intensive, we
> shouldn't require the UA to burn extra cycles doing unnecessary work.
I agree. For the normal as-time-passes changes to currentTime I don't
think an event is needed. When currentTime is changed either directly or
though looping (if we end up supporting some type of looping) it makes
sense to dispatch an event.
More information about the whatwg