W3C home > Mailing lists > Public > public-html-comments@w3.org > October 2009

Re: Video DOM API

From: Simon Pieters <simonp@opera.com>
Date: Thu, 08 Oct 2009 14:29:08 +0200
To: "Gervase Markham" <gerv@gerv.net>, public-html-comments@w3.org
Message-ID: <op.u1heaunuidj3kv@zcorpandell.linkoping.osa>
On Thu, 08 Oct 2009 13:14:37 +0200, Gervase Markham <gerv@gerv.net> wrote:

> On a <video> element (I haven't tried <audio>), if you change the src=  
> attribute to a new file, you have to call .load() before .play(),  
> otherwise it replays the old file. This lost me half an hour of  
> debugging, and recently another person posted in the Mozilla newsgroups  
> having exactly the same problem.
> I am told by an informed source (Boris Zbarsky) that the spec for  
> <video> requires this behaviour. Having spent ten minutes reading the  
> highly comprehensive specification, I could not find the location where  
> it says this. However, I believe him :-)

"If a src attribute of a media element that is in a Document and whose  
networkState has the value NETWORK_EMPTY is set or changed, the user agent  
must invoke the media element's resource selection algorithm."

If you have already played a video, networkState is not NETWORK_EMPTY, so  
the resource selection algorithm is not invoked (and thus play() will play  
the already-loaded video).

> Question: why? This is counter-intuitive. Under what circumstances would  
> you want to set the src= attribute of a <video> tag to a file which you  
> did not want the loading process to begin immediately? Can we eliminate  
> the requirement, e.g. by having play() implicitly call load() if it  
> hasn't been called?

Maybe we could remove the networkState check when the src attribute is set  
or changed. Should the "in a Document" check be removed, too? That is, do  
you want to be able to do

var a = new Audio('foo');
a.onended = function() { a.src = 'bar'; a.onended = null; }


(You wouldn't need to invoke play() again, because the media isn't paused  
when it has ended.)

What do you think should happen when using <source> elements?

Simon Pieters
Opera Software
Received on Thursday, 8 October 2009 12:29:59 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:26:25 UTC