[whatwg] <video> implicitly invoke the load() method
Philip Jägenstedt
philipj at opera.com
Mon Aug 18 09:09:23 PDT 2008
http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#load
There are a number of conditions for media elements where the user agent
"must implicitly invoke the load() method on the media element as soon
as all other scripts have finished executing":
* a source element is inserted into a media element that is already in a
document and whose networkState is in the EMPTY state
* the src attribute of a media element that is already in a document and
whose networkState is in the EMPTY state is added, changed, or removed
* a media element whose networkState has the value EMPTY is inserted
into a document
Now consider this markup
<video src="foo"></video>
with this script dynamically changing the sources
video = document.getElementById("video");
video.removeAttribute("src"); // implicit delayed load
source = document.createElement("source");
source.src = "bar";
source.media = "projection";
video.appendChild(source); // implicit delayed load
source = document.createElement("source");
source.src = "baz";
source.media = "screen";
video.appendChild(source); // implicit delayed load
video.play() // i want to play now!
play() will call load() before returning, so after this has finished
there shouldn't be any need to load() any more. However, there is no
less than 3 calls to load() waiting. Playback will begin, but will stop
as soon as the first of those delayed loads are invoked.
I believe that the spec actually may allow the N implicit loads to be
treated as 1, but at the very least there must be that 1, which is still
too many in this case. I doubt many authors will realize all the things
which may cause an implicit load, so I think the spec needs to allow for
this to be made simpler (from the script author's point of view). More
importantly, there's absolutely no need to implicitly call load once its
been explicitly called once.
I would suggest the following solution:
If when the time comes to invoke the load() method it has already been
invoked (directly or via another implicit invocation triggered by the
same script) then don't call it again.
Comments? I'm not sure exactly how to change the spec, but if we agree
that this needs fixing we can come back to that.
--
Philip Jägenstedt
Opera Software
More information about the whatwg
mailing list