[MSE] Bug 23442 - Fix example to work when seeking in the 'ended' state.
--- a/media-source/media-source-respec.html Tue Sep 24 00:18:51 2013 -0700
+++ b/media-source/media-source-respec.html Fri Oct 04 16:26:59 2013 -0700
@@ -2301,6 +2301,10 @@
<script>
function onSourceOpen(videoTag, e) {
var mediaSource = e.target;
+
+ if (mediaSource.sourceBuffers.length > 0)
+ return;
+
var sourceBuffer = mediaSource.addSourceBuffer('video/webm; codecs="vorbis,vp8"');
videoTag.addEventListener('seeking', onSeeking.bind(videoTag, mediaSource));
@@ -2327,7 +2331,7 @@
}
function appendNextMediaSegment(mediaSource) {
- if (mediaSource.readyState == "ended")
+ if (mediaSource.readyState == "closed")
return;
// If we have run out of stream data, then signal end of stream.
@@ -2348,14 +2352,19 @@
return;
}
+ // NOTE: If mediaSource.readyState == “ended”, this appendBuffer() call will
+ // cause mediaSource.readyState to transition to "open". The web application
+ // should be prepared to handle multiple “sourceopen” events.
mediaSource.sourceBuffers[0].appendBuffer(mediaSegment);
}
function onSeeking(mediaSource, e) {
var video = e.target;
- // Abort current segment append.
- mediaSource.sourceBuffers[0].abort();
+ if (mediaSource.readyState == "open") {
+ // Abort current segment append.
+ mediaSource.sourceBuffers[0].abort();
+ }
// Notify the media segment loading code to start fetching data at the
// new playback position.
--- a/media-source/media-source.html Tue Sep 24 00:18:51 2013 -0700
+++ b/media-source/media-source.html Fri Oct 04 16:26:59 2013 -0700
@@ -429,7 +429,7 @@
</p>
<h1 class="title" id="title">Media Source Extensions</h1>
- <h2 id="w3c-editor-s-draft-24-september-2013"><abbr title="World Wide Web Consortium">W3C</abbr> Editor's Draft 24 September 2013</h2>
+ <h2 id="w3c-editor-s-draft-04-october-2013"><abbr title="World Wide Web Consortium">W3C</abbr> Editor's Draft 04 October 2013</h2>
<dl>
<dt>This version:</dt>
@@ -2654,6 +2654,10 @@
<pre class="code"><script>
function onSourceOpen(videoTag, e) {
var mediaSource = e.target;
+
+ if (mediaSource.sourceBuffers.length > 0)
+ return;
+
var sourceBuffer = mediaSource.addSourceBuffer('video/webm; codecs="vorbis,vp8"');
videoTag.addEventListener('seeking', onSeeking.bind(videoTag, mediaSource));
@@ -2680,7 +2684,7 @@
}
function appendNextMediaSegment(mediaSource) {
- if (mediaSource.readyState == "ended")
+ if (mediaSource.readyState == "closed")
return;
// If we have run out of stream data, then signal end of stream.
@@ -2701,14 +2705,19 @@
return;
}
+ // NOTE: If mediaSource.readyState == “ended”, this appendBuffer() call will
+ // cause mediaSource.readyState to transition to "open". The web application
+ // should be prepared to handle multiple “sourceopen” events.
mediaSource.sourceBuffers[0].appendBuffer(mediaSegment);
}
function onSeeking(mediaSource, e) {
var video = e.target;
- // Abort current segment append.
- mediaSource.sourceBuffers[0].abort();
+ if (mediaSource.readyState == "open") {
+ // Abort current segment append.
+ mediaSource.sourceBuffers[0].abort();
+ }
// Notify the media segment loading code to start fetching data at the
// new playback position.
@@ -2738,7 +2747,7 @@
<section id="acknowledgements">
<!--OddPage--><h2><span class="secno">14. </span>Acknowledgments</h2>
- The editors would like to thank Alex Giladi, Bob Lund, Cyril Concolato, David Dorwin, David Singer, Duncan Rowden, Frank Galligan, Glenn Adams, Jerry Smith, Joe Steele, John Simmons, Kevin Streeter, Mark Vickers, Matt Ward, Michael Thornburgh, Philip Jägenstedt, Pierre Lemieux, Ralph Giles, and Steven Robertson for their contributions to this specification.
+ The editors would like to thank Alex Giladi, Bob Lund, Cyril Concolato, David Dorwin, David Singer, Duncan Rowden, Frank Galligan, Glenn Adams, Jerry Smith, Joe Steele, John Simmons, Kevin Streeter, Mark Vickers, Matt Ward, Michael Thornburgh, Philip Jägenstedt, Pierre Lemieux, Ralph Giles, Steven Robertson, and Tatsuya Igarashi for their contributions to this specification.
</section>
<section id="revision-history">
--- a/media-source/media-source.js Tue Sep 24 00:18:51 2013 -0700
+++ b/media-source/media-source.js Fri Oct 04 16:26:59 2013 -0700
@@ -109,6 +109,7 @@
"Cyril Concolato",
"Ralph Giles",
"David Singer",
+ "Tatsuya Igarashi",
];
contributors.sort();