[whatwg] Adding and removing media source elements
Philip Jägenstedt
philipj at opera.com
Tue Feb 3 01:04:01 PST 2009
On Tue, 03 Feb 2009 05:44:07 +0100, Ian Hickson <ian at hixie.ch> wrote:
> On Tue, 3 Feb 2009, Chris Pearce wrote:
>>
>> (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.
>
> Doing this would cause the first file to be downloaded multiple times in
> a
> row, leading to excessive network usage.
>
Surely this can't be the only reason? User agents are free to
speculatively keep the current source loading when src/source changes and
to stop loading it only if the "current media resource" does change. That,
and caching, should be enough.
I have always imagined that the reason for the conditioned load() is to
not interrupt playback by fiddling with the DOM or doing something like
v.src=v.src (although I'm quite sure that doesn't count as changing the
attribute). However, now I can't convince myself that this makes any
sense, since surely if you change src/source you actually do want to
change the effective source (and load() is scheduled to run after the
current script, so there's no risk of it being run too early).
Related, since load() is async it depends on timing whether or not
<video id=v></video>
<script>
v = document.getElementById('v');
v.src = 'test';
</script>
causes the source 'test' to be loaded, as the network state may not be
NETWORK_EMPTY when the src attribute is set. The same goes for adding
source child elements of course. Yes, this is the same issue as
http://lists.w3.org/Archives/Public/public-html/2009Jan/0103.html and
would be resolved by calling load() unconditionally.
--
Philip Jägenstedt
Opera Software
More information about the whatwg
mailing list