[Bug 12175] <video> the order of the loadedmetadata, loadeddata and suspend event is not defined

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

--- Comment #2 from Philip Jägenstedt <philipj@opera.com> 2011-04-28 09:07:12 UTC ---
This is what I've implemented (but not yet shipped) in Opera.

A state machine takes as its input 5 sub-states:

* current preload state: the preload state as per the spec (depends on content
attribute only)

* current network state: the actual network state as per the spec

* current ready state: the actual ready state as per the spec

* pending ready state: a target (maximum) ready state that depends on preload

* the playback ended state: as per the spec

The pending ready state is updated whenever the coerced preload state is
changed or when the playback ended state changes. If coerced preload is "none"
then pending ready is HAVE_NOTHING. If coerced preload is "metadata" or if
playback has ended, then the pending ready is HAVE_METADATA. Otherwise, the
pending ready state is HAVE_ENOUGH_DATA.

As its output it has:

* coerced preload state: the preload state actually used internally (not
exposed to scripts, that's always just a reflection of the content attribute,
limited to known values)

* coerced network state: what scripts see in networkState

* coerced ready state: what scripts see in readyState

Whenever any of the input states are changed, the following rules are applied
(in order):

* coerced preload = max(coerced preload, current preload), i.e. it can only
increase, as going from e.g. auto to none makes no sense.

* if coerced ready state < pending ready state and coerced network == IDLE,
then coerced network state is set to LOADING, regardless of the current network
state. (this clamps networkState to be LOADING while readyState is expected to
go through positive transitions, and ensures that the suspend event is only
fired once the pending ready state has been reached).

* if current network state != coerced network state and it's not because of the
clamping in the previous step, update coerced network state to current network
state.

* if coerced ready state < min(current ready state, pending ready state), then
increase coerced ready state. (this ensures that readyState is not allowed to
increase past HAVE_CURRENT_DATA for preload=metadata, for example)

* if coerced ready state > current ready state, then decrease coerced ready
state.

The rules are applied over and over until none of them apply (i.e. until there
are no more transitions on the coerced states).

-- 
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, 28 April 2011 09:07:15 UTC