Bug 1451149 - P2. Don't fire the "stalled" event when using MSE. r?bryce
When using a media element with a Media Source, the resource fetching algorithm is to be called in "local" mode:
https://www.w3.org/TR/media-source/#mediasource-attach
"Continue the resource fetch algorithm by running the remaining "Otherwise (mode is local)" steps, with these clarifications"
https://html.spec.whatwg.org/multipage/media.html#concept-media-load-resource
Under the local mode, the steps that would cause the element to fire suspend, stalled or progress can never occur.
We only prevent the stalled event to be fired, many websites rely on the progress event to be fired (such as when the init segment has been parsed). The HTML5 media spec will be amended to clearly indicate that progress is to be fired even with mediasource
MozReview-Commit-ID: DkoQzoV0JzO
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -5712,19 +5712,19 @@ HTMLMediaElement::CheckProgress(bool aHa
}
}
// Download statistics may have been updated, force a recheck of the
// readyState.
UpdateReadyStateInternal();
}
if (now - mDataTime >= TimeDuration::FromMilliseconds(STALL_MS)) {
- DispatchAsyncEvent(NS_LITERAL_STRING("stalled"));
-
- if (mMediaSource) {
+ if (!mMediaSource) {
+ DispatchAsyncEvent(NS_LITERAL_STRING("stalled"));
+ } else {
ChangeDelayLoadStatus(false);
}
NS_ASSERTION(mProgressTimer, "detected stalled without timer");
// Stop timer events, which prevents repeated stalled events until there
// is more progress.
StopProgress();
}
--- a/dom/media/mediasource/test/test_ChangeWhileWaitingOnMissingData_mp4.html
+++ b/dom/media/mediasource/test/test_ChangeWhileWaitingOnMissingData_mp4.html
@@ -18,17 +18,17 @@ runWithMSE(function(ms, el) {
const sb = ms.addSourceBuffer("video/mp4");
fetchAndLoad(sb, "bipbop/bipbop_480_624kbps-video", [ "init" ], ".mp4")
.then(fetchAndLoad.bind(null, sb, "bipbop/bipbop_480_624kbps-video", range(1, 3), ".m4s"))
.then(function() {
el.play();
// let seek to the last audio frame.
// The seek will complete and then playback will stall.
el.currentTime = 1.532517;
- return Promise.all([ once(el, "seeked"), once(el, "stalled") ]);
+ return Promise.all([ once(el, "seeked"), once(el, "waiting") ]);
})
.then(function() {
info("seek completed");
return fetchAndLoad(sb, "bipbop/bipbop", [ "init" ], ".mp4");
})
.then(fetchAndLoad.bind(null, sb, "bipbop/bipbop", range(1, 4), ".m4s"))
.then(function() {
ms.endOfStream();