dom/media/mediasource/test/test_ChangeWhileWaitingOnMissingData_mp4.html
author Jean-Yves Avenard <jyavenard@mozilla.com>
Mon, 14 May 2018 11:32:09 +0200
changeset 476479 b3350fc6da3aca627f12da57ff55805fdbe7c6b2
parent 475443 abc9351a9c159afb31d58fc29beda855ad4f832b
child 477049 5f5b118631b0a235a75c90c16b75db31d0de0cf0
permissions -rw-r--r--
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

<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
  <title>MSE: resume from waiting even after format change occurred</title>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="text/javascript" src="mediasource.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test"><script class="testbody" type="text/javascript">

SimpleTest.waitForExplicitFinish();

runWithMSE(function(ms, el) {
  el.controls = true;
  once(ms, "sourceopen").then(function() {
    ok(true, "Receive a sourceopen event");
    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, "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();
      return once(el, "ended");
    }).then(function() {
      SimpleTest.finish();
    });
  });
});

</script>
</pre>
</body>
</html>