test_AudioChange_mp4.html (1515B)
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 without error. 16 17 runWithMSE(async (ms, el) => { 18 el.controls = true; 19 await once(ms, "sourceopen"); 20 ok(true, "Receive a sourceopen event"); 21 logEvents(el); 22 23 const audiosb = ms.addSourceBuffer("audio/mp4"); 24 el.addEventListener("error", e => { 25 ok(false, `should not fire ${e.type} event`); 26 SimpleTest.finish(); 27 }); 28 is(el.readyState, el.HAVE_NOTHING, "readyState is HAVE_NOTHING"); 29 let p = once(el, "loadedmetadata"); 30 await fetchAndLoad(audiosb, "aac20-48000-64000-", ["init"], ".mp4"); 31 await p; 32 ok(true, "got loadedmetadata event"); 33 p = Promise.all([once(el, "loadeddata"), once(el, "canplay")]); 34 await fetchAndLoad(audiosb, "aac20-48000-64000-", ["1"], ".m4s"); 35 await p; 36 ok(true, "got canplay event"); 37 el.play(); 38 await fetchAndLoad(audiosb, "aac51-48000-128000-", ["init"], ".mp4"); 39 await fetchAndLoad(audiosb, "aac51-48000-128000-", ["2"], ".m4s"); 40 ms.endOfStream(); 41 await once(el, "ended"); 42 ok(el.currentTime >= 6, "played to the end"); 43 SimpleTest.finish(); 44 }); 45 46 </script> 47 </pre> 48 </body> 49 </html>