Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[e] (0) Add an example of forcing fallback from <source>.
git-svn-id: http://svn.whatwg.org/webapps@4685 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Feb 10, 2010
1 parent a44fbad commit 5cd101c
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
24 changes: 24 additions & 0 deletions complete.html
Expand Up @@ -21749,6 +21749,30 @@ <h4 id=the-source-element><span class=secno>4.8.8 </span>The <dfn><code>source</

</div>

<div class=example>

<p>If the author isn't sure if the user agents will all be able to
render the media resources provided, the author can listen to the
<code title=event-error>error</code> event on the last
<code><a href=#the-source-element>source</a></code> element and trigger fallback behaviour:</p>

<pre>&lt;video controls autoplay&gt;
&lt;source src='video.mp4' type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'&gt;
&lt;source src='video.ogv' type='video/ogg; codecs="theora, vorbis"'
onerror="fallback(parentNode)"&gt;
...
&lt;/video&gt;
&lt;script&gt;
function fallback(video) {
// replace &lt;video&gt; with its contents
while (video.hasChildNodes())
video.parentNode.insertBefore(video.firstChild, video);
video.parentNode.removeChild(video);
}
&lt;/script&gt;</pre>

</div>



<h4 id=media-elements><span class=secno>4.8.9 </span>Media elements</h4>
Expand Down
24 changes: 24 additions & 0 deletions index
Expand Up @@ -21648,6 +21648,30 @@ interface <dfn id=htmlaudioelement>HTMLAudioElement</dfn> : <a href=#htmlmediael

</div>

<div class=example>

<p>If the author isn't sure if the user agents will all be able to
render the media resources provided, the author can listen to the
<code title=event-error>error</code> event on the last
<code><a href=#the-source-element>source</a></code> element and trigger fallback behaviour:</p>

<pre>&lt;video controls autoplay&gt;
&lt;source src='video.mp4' type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'&gt;
&lt;source src='video.ogv' type='video/ogg; codecs="theora, vorbis"'
onerror="fallback(parentNode)"&gt;
...
&lt;/video&gt;
&lt;script&gt;
function fallback(video) {
// replace &lt;video&gt; with its contents
while (video.hasChildNodes())
video.parentNode.insertBefore(video.firstChild, video);
video.parentNode.removeChild(video);
}
&lt;/script&gt;</pre>

</div>



<h4 id=media-elements><span class=secno>4.8.9 </span>Media elements</h4>
Expand Down
24 changes: 24 additions & 0 deletions source
Expand Up @@ -23279,6 +23279,30 @@ interface <dfn>HTMLAudioElement</dfn> : <span>HTMLMediaElement</span> {};</pre>

</div>

<div class="example">

<p>If the author isn't sure if the user agents will all be able to
render the media resources provided, the author can listen to the
<code title="event-error">error</code> event on the last
<code>source</code> element and trigger fallback behaviour:</p>

<pre>&lt;video controls autoplay>
&lt;source src='video.mp4' type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
&lt;source src='video.ogv' type='video/ogg; codecs="theora, vorbis"'
onerror="fallback(parentNode)">
...
&lt;/video>
&lt;script>
function fallback(video) {
// replace &lt;video> with its contents
while (video.hasChildNodes())
video.parentNode.insertBefore(video.firstChild, video);
video.parentNode.removeChild(video);
}
&lt;/script></pre>

</div>



<h4>Media elements</h4>
Expand Down

0 comments on commit 5cd101c

Please sign in to comment.