- From: Simon Pieters <simonp@opera.com>
- Date: Thu, 08 Oct 2009 16:45:16 +0200
- To: "Gervase Markham" <gerv@gerv.net>, public-html-comments@w3.org
On Thu, 08 Oct 2009 14:53:59 +0200, Gervase Markham <gerv@gerv.net> wrote: > On 08/10/09 13:29, Simon Pieters wrote: >> 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.play(); >> a.onended = function() { a.src = 'bar'; a.onended = null; } > > That seems like the obvious way one would implement the chaining of > videos, isn't it? Although it doesn't allow for pre-loading and > therefore seamless linking unless you've loaded 'bar' in another <audio> > somewhere else previously. Hmm... > > I think I want to be able to do: > > var a = new Audio('foo'); > a.play(); > a.src = 'bar'; > a.load(); > a.onended = function() { a.play(); a.onended = null; } > > which gives me the preloading as well without needing an extra element. So you want the media element to load two resources at the same time? I'm very skeptical about this idea. What should happen when the user clicks pause and then play, should it suddenly switch to the new media? I don't see the problem with having separate media elements for separate media: var a1 = new Audio('foo'); var a2 = new Audio('bar'); a1.play(); a1.onended = function() { a2.play(); a1 = null; /* allow a1 to be garbage collected */ } For video, you can do the same thing and just use replaceChild(): <video src='foo' autoplay controls></video> <script> var v1 = document.querySelector('video'); var v2 = document.createElement('video'); v2.autobuffer = true; v2.controls = true; v2.src = 'bar'; v2.load(); v1.onended = function() { v1.parentNode.replaceChild(v1, v2); } </script> >> What do you think should happen when using <source> elements? > > Good question. I think that if I add a <source> element, it should be > automatically load()ed. But if I call play(), then the resource > selection algorithm should be used at that point to tell which video > actually plays. Not sure I follow. Currently, inserting a <source> into a media element that is in a document and has networkState NETWORK_EMPTY will run the resource selection algorithm. Inserting another <source> will only be used if the first <source> fails. -- Simon Pieters Opera Software
Received on Thursday, 8 October 2009 14:46:03 UTC