<div class="gmail_quote">On Thu, Dec 9, 2010 at 1:42 AM, Simon Pieters <span dir="ltr"><<a href="mailto:simonp@opera.com">simonp@opera.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Thu, 09 Dec 2010 02:58:12 +0100, Ian Hickson <<a href="mailto:ian@hixie.ch" target="_blank">ian@hixie.ch</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Wed, 1 Sep 2010, Simon Pieters wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I think it might be good to run the media element load algorithm when<br>
setting or changing src on <source> (that has a media element as its<br>
parent), but not type and media (what's the use case for type and<br>
media?). However it would fire an 'emptied' event for each <source> that<br>
changed, which is kind of undesirable. Maybe the media element load<br>
algorithm should only be invoked if src is set or changed on a <source><br>
that has no previous sibling <source> elements?<br>
</blockquote>
<br>
What's the use case? Just set .src before you insert the element.<br>
</blockquote>
<br></div>
The use case under discussion is changing to another video. So the element is already inserted and already has src.<br>
<br>
Something like:<br>
<br>
<video controls autoplay><br>
<source src=video1.webm type=video/webm><br>
<source src=video1.mp4 type=video/mp4><br>
</video><br>
<script><br>
function loadVideo(src) {<br>
var video = document.getElementsByTagName('video')[0];<br>
sources = video.getElementsByTagName('source');<br>
sources[0].src = src + '.webm';<br>
sources[1].src = src + '.mp4';<br>
}<br>
</script><br>
<input type="button" value="See video 1" onclick="loadVideo('video1')"><br>
<input type="button" value="See video 2" onclick="loadVideo('video2')"><br>
<input type="button" value="See video 3" onclick="loadVideo('video3')"><br><font color="#888888">
<br></font></blockquote><div><br></div><div>Is that really any better than:</div><div><br></div><div>function loadVideo(src) {</div><div><meta http-equiv="content-type" content="text/html; charset=utf-8"> var video = document.getElementsByTagName('video')[0];<br>
</div><div> if(video.canPlayType("video/webm") != "") {</div><div> video.src = src + '.webm';</div><div> }</div><div> else {</div><div> video.src = src + '.mp4';</div><div> }</div>
<div>
}</div><div><br></div><div>-Kevin</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><font color="#888888">
-- <br>
Simon Pieters<br>
Opera Software<br>
</font></blockquote></div><br>