W3C home > Mailing lists > Public > whatwg@whatwg.org > February 2009

[whatwg] Adding and removing media source elements

From: Philip Jägenstedt <philipj@opera.com>
Date: Tue, 03 Feb 2009 10:04:01 +0100
Message-ID: <op.uorp4zf4atwj1d@spock.linkoping.osa>
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
Received on Tuesday, 3 February 2009 01:04:01 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:09 UTC