tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_AudioChange_mp4_WebAudio.html (1686B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>MSE: basic functionality</title>
      5  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6  <script type="text/javascript" src="mediasource.js"></script>
      7  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
      8 </head>
      9 <body>
     10 <pre id="test">
     11 <script class="testbody" type="text/javascript">
     12 
     13 SimpleTest.waitForExplicitFinish();
     14 
     15 // This test checks loading a stereo segment, followed by a 5.1 segment plays
     16 // without error, when the audio is being routed to an AudioContext.
     17 
     18 const ac = new AudioContext();
     19 
     20 runWithMSE(async (ms, el) => {
     21  el.controls = true;
     22  const source = ac.createMediaElementSource(el);
     23  source.connect(ac.destination);
     24 
     25  await once(ms, "sourceopen");
     26  ok(true, "Receive a sourceopen event");
     27  logEvents(el);
     28 
     29  const audiosb = ms.addSourceBuffer("audio/mp4");
     30  el.addEventListener("error", e => {
     31    ok(false, `should not fire ${e.type} event`);
     32    SimpleTest.finish();
     33  });
     34  is(el.readyState, el.HAVE_NOTHING, "readyState is HAVE_NOTHING");
     35  let p = once(el, "loadedmetadata");
     36  await fetchAndLoad(audiosb, "aac20-48000-64000-", ["init"], ".mp4");
     37  await p;
     38  ok(true, "got loadedmetadata event");
     39  p = Promise.all([once(el, "loadeddata"), once(el, "canplay")]);
     40  await fetchAndLoad(audiosb, "aac20-48000-64000-", ["1"], ".m4s");
     41  await p;
     42  ok(true, "got canplay event");
     43  el.play();
     44  await fetchAndLoad(audiosb, "aac51-48000-128000-", ["init"], ".mp4");
     45  await fetchAndLoad(audiosb, "aac51-48000-128000-", ["2"], ".m4s");
     46  ms.endOfStream();
     47  await once(el, "ended");
     48  ok(el.currentTime >= 6, "played to the end");
     49  SimpleTest.finish();
     50 });
     51 
     52 </script>
     53 </pre>
     54 </body>
     55 </html>