W3C home > Mailing lists > Public > whatwg@whatwg.org > November 2008

[whatwg] Video Element Events? - Use Case: Custom Progress Bar

From: Jonas Sicking <jonas@sicking.cc>
Date: Mon, 17 Nov 2008 11:48:46 -0800
Message-ID: <4921CA9E.2040408@sicking.cc>
Robert O'Callahan wrote:
> On Mon, Nov 17, 2008 at 3:19 PM, Jonas Sicking <jonas at sicking.cc> wrote:
> 
>     Ian Hickson wrote:
> 
>             Video and audio playback is already extremely CPU intensive,
>             we shouldn't require the UA to burn extra cycles doing
>             unnecessary work.
> 
> 
>         I agree. That was exactly the thinking behind the timeupdate
>         event. It allows the UA to determine how fast to update the UI
>         without hurting performance. Basically it puts the UA in charge
>         of the performance critical aspects instead of hoping that the
>         author will work it out.
> 
> 
>     Though if all implementations are saying that it has the opposite
>     effect then clearly we need to look into if something went wrong :)
> 
> 
> I don't think firing timeupdate on every frame is *that* bad for us, to 
> be honest.

It seems like a pretty big waste of resources to have the following 
script executing 50 times per second:

function timeupdatehandler(e) {
   video = e.target;
   completed = video.currentTime / video.duration;
   thumb = document.getElementById('thumb' + video.id);
   thumb.style.left =
     calcScreenPositionUsingOffsetLeftRecursion(thumb.parentNode) +
     thumb.parentNode.offsetWidth * completed;
   progress = document.getElementById('progress' + video.id);
   progress.style.width =
     progress.parentNode.offsetWidth * completed;
}

Sure, we can pull it off, but why do it? At it certainly doesn't seem to 
archive the goal of the event which apparently is to reduce the amount 
of CPU resources used.

/ Jonas
Received on Monday, 17 November 2008 11:48:46 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:07 UTC