[whatwg] <video> resource selection algorithm and NETWORK_NO_SOURCE

On Thu, 09 Dec 2010 02:58:12 +0100, Ian Hickson <ian at hixie.ch> wrote:

> On Wed, 1 Sep 2010, Simon Pieters wrote:
>>
>> I think it might be good to run the media element load algorithm when
>> setting or changing src on <source> (that has a media element as its
>> parent), but not type and media (what's the use case for type and
>> media?). However it would fire an 'emptied' event for each <source> that
>> changed, which is kind of undesirable. Maybe the media element load
>> algorithm should only be invoked if src is set or changed on a <source>
>> that has no previous sibling <source> elements?
>
> What's the use case? Just set .src before you insert the element.

The use case under discussion is changing to another video. So the element  
is already inserted and already has src.

Something like:

<video controls autoplay>
  <source src=video1.webm type=video/webm>
  <source src=video1.mp4 type=video/mp4>
</video>
<script>
function loadVideo(src) {
   var video = document.getElementsByTagName('video')[0];
   sources = video.getElementsByTagName('source');
   sources[0].src = src + '.webm';
   sources[1].src = src + '.mp4';
}
</script>
<input type="button" value="See video 1" onclick="loadVideo('video1')">
<input type="button" value="See video 2" onclick="loadVideo('video2')">
<input type="button" value="See video 3" onclick="loadVideo('video3')">

-- 
Simon Pieters
Opera Software

Received on Thursday, 9 December 2010 01:42:45 UTC