Bug 1357040: P7. Only use sourcebuffer again once previous operation completed. r?gerald
It was incorrect to assume that once "loadeddata" event fired the sourcebuffer would be usable again. Only the "updateend" event guarantees such condition.
MozReview-Commit-ID: HcyaLWjjBlp
--- a/dom/media/mediasource/test/test_TruncatedDuration.html
+++ b/dom/media/mediasource/test/test_TruncatedDuration.html
@@ -45,34 +45,30 @@ function do_seeked(e) {
// test playback position was updated (bug 1130839).
is(v.currentTime, v.duration, "current time was updated");
is(v._sb.buffered.length, 1, "One buffered range");
// Truncated mediasource duration will cause the video element to seek.
v.addEventListener("seeking", do_seeking);
});
}
-function do_loaded(e) {
- var v = e.target;
- v.removeEventListener("loadeddata", do_loaded);
- v.currentTime = v.duration / 2;
- is(v.currentTime, v.duration / 2, "current time was updated");
- ok(v.seeking, "seeking is true");
- v.addEventListener("seeked", do_seeked);
-}
-
runWithMSE(function (ms, v) {
ms.addEventListener("sourceopen", function () {
var sb = ms.addSourceBuffer("video/webm");
v._sb = sb;
v._ms = ms;
fetchWithXHR("seek.webm", function (arrayBuffer) {
sb.appendBuffer(new Uint8Array(arrayBuffer));
- v.addEventListener("loadeddata", do_loaded);
+ once(sb, "updateend", function() {
+ v.currentTime = v.duration / 2;
+ is(v.currentTime, v.duration / 2, "current time was updated");
+ ok(v.seeking, "seeking is true");
+ v.addEventListener("seeked", do_seeked);
+ });
});
});
});
</script>
</pre>
</body>
</html>
--- a/dom/media/mediasource/test/test_TruncatedDuration_mp4.html
+++ b/dom/media/mediasource/test/test_TruncatedDuration_mp4.html
@@ -44,40 +44,36 @@ function do_seeked(e) {
// test playback position was updated (bug 1130839).
is(v.currentTime, v.duration, "current time was updated");
is(v._sb.buffered.length, 1, "One buffered range");
// Truncated mediasource duration will cause the video element to seek.
v.addEventListener("seeking", do_seeking);
});
}
-function do_loaded(e) {
- var v = e.target;
- v.removeEventListener("loadeddata", do_loaded);
- // mp4 metadata states 10s when we only have 1.6s worth of video.
- v._sb.remove(v._sb.buffered.end(0), Infinity);
- once(v._sb, "updateend", function() {
- v._ms.duration = v._sb.buffered.end(0);
- is(v.duration, v._ms.duration, "current time updated with mediasource duration");
- v.currentTime = v.duration / 2;
- is(v.currentTime, v.duration / 2, "current time was updated");
- ok(v.seeking, "seeking is true");
- v.addEventListener("seeked", do_seeked);
- });
-}
-
runWithMSE(function (ms, v) {
ms.addEventListener("sourceopen", function () {
var sb = ms.addSourceBuffer("video/mp4");
v._sb = sb;
v._ms = ms;
fetchWithXHR("bipbop/bipbop2s.mp4", function (arrayBuffer) {
sb.appendBuffer(new Uint8Array(arrayBuffer));
- v.addEventListener("loadeddata", do_loaded);
+ once(sb, "updateend", function() {
+ // mp4 metadata states 10s when we only have 1.6s worth of video.
+ v._sb.remove(v._sb.buffered.end(0), Infinity);
+ once(v._sb, "updateend", function() {
+ v._ms.duration = v._sb.buffered.end(0);
+ is(v.duration, v._ms.duration, "current time updated with mediasource duration");
+ v.currentTime = v.duration / 2;
+ is(v.currentTime, v.duration / 2, "current time was updated");
+ ok(v.seeking, "seeking is true");
+ v.addEventListener("seeked", do_seeked);
+ });
+ });
});
});
});
</script>
</pre>
</body>
</html>