[whatwg] media element playback rates

Ian Hickson ian at hixie.ch
Fri Nov 2 10:34:13 PDT 2007


On Fri, 2 Nov 2007, Dave Singer wrote:
> 
> About playbackRate and defaultPlaybackRate in the current specification of
> media elements, the logic that's currently necessary to set a media element to
> play at rate n is somewhat convoluted:
> 
> 	If the media is paused
> 		1) Set the defaultPlaybackRate to n.
> 		2) Issue play().
> 	If the media is not paused
> 		- Set the playbackRate to n.
> 
> And there's a distinct lack of permanence to setting playbackRate on 
> playing media to alter its rate. Once media is paused, the play() method 
> will reset the rate of the media (and playbackRate itself) to 
> defaultPlaybackRate instead of to the previous value of playbackRate, 
> which we think is unexpected.

The current design is built around three use cases:

 1. Being able to implement fast-forward, rewind, or slow-motion easily.
 2. Being able to change the playback rate for watching videos quickly.
 3. Being able to do both in the same player.

In the current model:

Fast-forward and rewind just consists of calling play() to ensure the 
playback head is moving and then changing 'playbackRate', resetting to 
normal is just a call to play(); changing the default playback rate 
without affecting that consists of changing 'defaultPlaybackRate' and, if 
the UA isn't in a fast-forward, rewind, or slow-motion mode, and isn't 
paused, also calling 'play()'.

We could optimise this by making defaultPlaybackRate affect playbackRate 
if playbackRate == old_defaultPlaybackRate, though. Would that work?


> Similarly, the logic required to determine the rate at which media is 
> playing or is about to play is convoluted. When listening for ratechange 
> events, scripts must perform different checks depending on whether the 
> media is currently playing.

Why? playbackRate always represents the current playback rate.

We could make changing defaultPlaybackRate when the content is paused 
affect playbackRate, though. Would that work?


> Proposal: [...]

As far as I can tell this would significantly complicate implementing the 
two use cases mentioned above together.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'



More information about the whatwg mailing list