On Mon, Jul 26, 2010 at 11:25 PM, Philip Jägenstedt <span dir="ltr"><<a href="mailto:philipj@opera.com">philipj@opera.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<div><div></div><div class="h5">On Mon, 26 Jul 2010 15:02:34 +0200, Silvia Pfeiffer <<a href="mailto:silviapfeiffer1@gmail.com" target="_blank">silviapfeiffer1@gmail.com</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
On Mon, Jul 26, 2010 at 7:49 PM, Philip Jägenstedt <<a href="mailto:philipj@opera.com" target="_blank">philipj@opera.com</a>>wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
On Mon, 26 Jul 2010 02:58:07 +0200, Silvia Pfeiffer <<br>
<a href="mailto:silviapfeiffer1@gmail.com" target="_blank">silviapfeiffer1@gmail.com</a>> wrote:<br>
<br>
 On Sun, Jul 25, 2010 at 3:31 PM, Maciej Stachowiak <<a href="mailto:mjs@apple.com" target="_blank">mjs@apple.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
On Jul 23, 2010, at 7:16 AM, Philip Jägenstedt wrote:<br>
<br>
Silvia made we aware of discrepancy in how browsers implement the<br>
resource<br>
selection algorithm, see forwarded message. It's my assessment that Opera<br>
is<br>
the only browser following the spec. I've filed this bug with Mozilla:<br>
<br>
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=581355" target="_blank">https://bugzilla.mozilla.org/show_bug.cgi?id=581355</a><br>
<br>
I've also reported bugs in Chrome and Safari, but can't see where they<br>
ended up.<br>
<br>
The reason I'm writing this email is that apparently everyone but myself<br>
has a different interpretation of the spec, so perhaps this is something<br>
we<br>
need to discuss. Does any other browser ever set the state<br>
NETWORK_NO_SOURCE<br>
at all? I speculated that perhaps other browsers aren't very strict about<br>
which parts of the algorithm are run synchronously and not, but even<br>
checking the networkState after a setTimeout it still isn't<br>
NETWORK_NO_SOURCE.<br>
<br>
Test case: <a href="http://people.opera.com/philipj/2010/07/23/networkState.html" target="_blank">http://people.opera.com/philipj/2010/07/23/networkState.html</a><br>
<br>
Please fix implementation or spec :)<br>
<br>
<br>
1) Which behavior is more useful?<br>
2) Sylvia's original issue was with play() - should we ensure that any<br>
time<br>
you call play(), it will cause the media resource to start playing once<br>
loaded? That seems like the real spec bug.<br>
<br>
<br>
</blockquote>
The problem there with play in Opera was that the @src was changed, but<br>
Opera doesn't run the resource selection algorithm to load it for play(),<br>
but instead expects to run load() first. The description of play() however<br>
clearly states as a first step:<br>
1. If the media<br>
element<<br>
<a href="http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#media-element" target="_blank">http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#media-element</a><br>
>'s<br>
networkState<<br>
<a href="http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#dom-media-networkstate" target="_blank">http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#dom-media-networkstate</a><br>
>attribute<br>
has the value<br>
NETWORK_EMPTY<<br>
<a href="http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#dom-media-network_empty" target="_blank">http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#dom-media-network_empty</a><br>


>,<br>
invoke the media<br>
element<<br>
<a href="http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#media-element" target="_blank">http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#media-element</a><br>
>'s<br>
resource selection<br>
algorithm<<br>
<a href="http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#concept-media-load-algorithm" target="_blank">http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#concept-media-load-algorithm</a><br>


><br>
<br>
.<br>
<br>
This is why we are discussing whether the networkState needs to be<br>
NETWORK_EMPTY or NETWORK_NO_SOURCE after initialisation of a media<br>
element.<br>
<br>
Incidentally, that has effects on other elements, too, such as for<br>
<source><br>
it is stated:<br>
If a source<<br>
<a href="http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#the-source-element" target="_blank">http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#the-source-element</a><br>
>element<br>
<br>
is inserted as a child of a media<br>
element<<br>
<a href="http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#media-element" target="_blank">http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#media-element</a><br>
>that<br>
has no<br>
src<<br>
<a href="http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#attr-media-src" target="_blank">http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#attr-media-src</a><br>
>attribute<br>
and whose<br>
networkState<<br>
<a href="http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#dom-media-networkstate" target="_blank">http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#dom-media-networkstate</a><br>
>has<br>
the value<br>
NETWORK_EMPTY<<br>
<a href="http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#dom-media-network_empty" target="_blank">http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#dom-media-network_empty</a><br>


>,<br>
<br>
the user agent must invoke the media<br>
element<<br>
<a href="http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#media-element" target="_blank">http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#media-element</a><br>
>'s<br>
resource selection<br>
algorithm<<br>
<a href="http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#concept-media-load-algorithm" target="_blank">http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#concept-media-load-algorithm</a><br>


><br>
<br>
.<br>
<br>
And for @src it is said:<br>
If a src<<br>
<a href="http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#attr-media-src" target="_blank">http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#attr-media-src</a><br>
>attribute<br>
of a media<br>
element<<br>
<a href="http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#media-element" target="_blank">http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#media-element</a><br>
>is<br>
<br>
set or changed, the user agent must invoke the media<br>
element<<br>
<a href="http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#media-element" target="_blank">http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#media-element</a><br>
>'s<br>
media element load<br>
algorithm<<br>
<a href="http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#media-element-load-algorithm" target="_blank">http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#media-element-load-algorithm</a><br>


>.<br>
(*Removing* the<br>
src<<br>
<a href="http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#attr-media-src" target="_blank">http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#attr-media-src</a><br>
>attribute<br>
<br>
does not do this, even if there are<br>
source<<br>
<a href="http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#the-source-element" target="_blank">http://www.whatwg.org/specs/web-apps/current-work/complete/video.html#the-source-element</a><br>
>elements<br>
<br>
present.)<br>
<br>
That is kinda strange, too, because really when @src is changed, resource<br>
selection has to be run first rather than media element load.<br>
<br>
</blockquote>
<br>
The load algorithm is just a wrapper for the resource selection algorithm<br>
that makes sure that a previously running resource selection algorithm is<br>
aborted in an orderly fashion and that the state is reset. What's strange?<br>
<br>
</blockquote>
<br>
I misread that, too. I thought it was pointing to the resource fetch<br>
algorithm and not the media element load algorithm. You're right - this part<br>
is fine.<br>
<br>
<br>
Incidentally, your test isn't complete. In my test file, I was actually<br>
setting the @src values of the <source> elements to resources that existed<br>
and then called the play() function. That activity should, IMO, work. All<br>
browser accept it, except for Opera, which never leaves step 21 because<br>
play() doesn't accept NETWORK_NO_SOURCE for re-running the resource<br>
selection algorithm. That was really my original problem.<br>
</blockquote>
<br></div></div>
I agree that it'd be good if this worked, all else equal. Unfortunately, making it work would require adding hooks for when the src attribute of source elements are changed. Since you want to change all of the src attributes before resource selection runs, you'd either have to delay its invocation (a.k.a. await a stable state) or have a situation where the first source is potentially processed 3 times, the second 2 times and the last 1 time.<br>


<br>
My solution:<div class="im"><br>
<br>
    <video controls width="400px"><br>
    </video><br></div>
    <script type="text/javascript"><br>
      var video = document.querySelector("video");<br>
      var exts = ["mp4", "webm", "ogv"];<br>
      exts.forEach(function(ext) {<br>
        var source = document.createElement("source");<br>
        source.src = "HelloWorld."+ext;<br>
        source.type = "video/"+ext;<br>
        video.appendChild(source);<br>
      });<br>
      video.play();<br>
    </script><br></blockquote><div> </div><div><br>Does this actually work in Opera now?<br><br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">


Of course, there must be some good reason to use scripts to begin with, as the result of this is always the same, so you might just as well use static markup.</blockquote><div><br><br>Sure, but this is only a snippet of an actual application. If, e.g., you want to step through a list of videos (maybe an automated playlist) using script and you need to provide at least two different formats with <source>, you'd want to run this algorithm frequently. While this is a good solution, authors may still end up doing it in sequence, in which case I guess you may indeed need to run resource selection three times: once every time a @src attribute is changed on a <source> element.<br>

<br>Cheers,<br>Silvia.<br></div></div>