[Bug 13871] <video> behavior when setting currentTime to current playback position

http://www.w3.org/Bugs/Public/show_bug.cgi?id=13871

--- Comment #8 from Glenn Adams <glenn@skynav.com> 2011-08-25 16:01:42 UTC ---
(In reply to comment #7)
> (In reply to comment #6)
> > (In reply to comment #5)
> > > 2. It's more reliable for page authors, as UI won't break when one happens to
> > > click the seek bar exactly at currentTime.
> > 
> > Could you describe how an early exit from the seeking algorithm, i.e., without
> > generating a seeking event, will "break" the page's UI?
> > 
> > I would expect it to act as a NO-OP, simply resulting in no update/change to a
> > seek bar.
> 
> Something like this:
> 
> var v = document.querySelector('video');
> var c = document.querySelector('.controls');
> var s = document.querySelector('.spinner');
> c.onclick = function() {
>   var newTime = /* calculate new pos based on click position and duration */;
>   v.currentTime = newTime;
>   /* if readyState was HAVE_NOTHING an exception was thrown and the next line
> is not reached */
>   s.display = 'block'; /* show seeking spinner on top of video/controls */
> };
> v.seeked = function() {
>   s.display = 'none';
> };
> 
> If the seeked event is not fired, the spinner won't be hidden possibly
> obscuring the video or the controls, in the worst case making it impossible to
> issue another seek which would get rid of it.
> 
> > Since various other states on the resource may result in a seek exception, a
> > realistic UI would not depend on every setting of currentTime to produce a
> > seeking event in the first place.
> 
> In the example, the spinner is not shown if an exception is thrown when setting
> currentTime.

ok, but one wonders about the wisdom of coding this to depend on exceptions;
that is certainly not a wise approach to rely upon exceptions for flow control
(cf. http://c2.com/cgi/wiki?DontUseExceptionsForFlowControl);

better code have been written as:

c.onclick = function() {
  if ( v.readyState > HTMLMediaElement.HAVE_NOTHING ) {
    var newTime = /* calculate new pos based on click position and duration */;
    v.currentTime = newTime;
    s.display = 'block';
  }
};

one might conclude your example was broken in the first place

-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

Received on Thursday, 25 August 2011 16:01:44 UTC