[whatwg] Adding and removing media source elements

Chris Pearce chris at pearce.org.nz
Mon Feb 2 20:06:14 PST 2009


I want to clarify something about <media>'s child <source> element... In 
the <source> element spec [ 
http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#the-source-element 
] it says:
> If a source element is inserted into a media element that is already 
> in a document and whose networkState is in the NETWORK_EMPTY state, 
> the user agent must queue a task that implicitly invokes the load() 
> method on the media element, and ignores any resulting exceptions.
So we only trigger a load when adding a child <source> element to a 
<media> element if the media element is in NETWORK_EMPTY networkState.

Additionally, in the spec for <media>'s src attribute [ 
http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#attr-media-src 
] it says:
> If the src attribute of a media element that is already in a document 
> and whose networkState is in the NETWORK_EMPTY state is added, 
> changed, or removed, the user agent must queue a task that implicitly 
> invokes the load() method on the media element, and ignores any 
> resulting exceptions. 
Almost the same, except that we invoke the load algorithm when the src 
is removed or changed in this case.

I have the following questions:

(1) Should removing a media element's child source element while the 
networkState is NETWORK_EMPTY cause the load() algorithm to be invoked? 
This would match the behviour of removing the media element's src 
attribute when networkState is NETWORK_EMPTY.

It seems that in order to start a load in an already loaded media 
element, you must change the src attribute or add source element 
children to the media element, and then call load() on the media 
element. Whereas when you initially create the media element, the first 
time you add the src attribute or add a child source element to the 
media element, you'll start an asynchronous load immediately.

(2) Why don't we invoke load() whenever a media element's src attribute 
or <source> children are changed, regardless of networkState? That way 
changes to the media's src/source other than the first change would have 
the same effect as first change, i.e. they'd have an immediate effect, 
causing load() to be invoked.

Thanks,
Chris Pearce.



More information about the whatwg mailing list