test_MultipleInitSegments_mp4.html (1486B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta http-equiv="content-type" content="text/html; charset=windows-1252"> 5 <title>MSE: Append buffer with multiple init segments</title> 6 <script src="/tests/SimpleTest/SimpleTest.js"></script> 7 <script type="text/javascript" src="mediasource.js"></script> 8 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 9 </head> 10 <body> 11 <pre id="test"> 12 <script class="testbody" type="text/javascript"> 13 14 SimpleTest.waitForExplicitFinish(); 15 16 runWithMSE(async (ms, v) => { 17 await once(ms, "sourceopen"); 18 const sb = ms.addSourceBuffer("video/mp4"); 19 const init = new Uint8Array(await fetchWithXHR("bipbop/bipbop_videoinit.mp4")); 20 const segment1 = new Uint8Array(await fetchWithXHR("bipbop/bipbop_video1.m4s")); 21 const segment2 = new Uint8Array(await fetchWithXHR("bipbop/bipbop_video2.m4s")); 22 const data = [init, segment1, init, segment2]; 23 const length = data.map(d => d.byteLength).reduce((a, b) => a + b, 0); 24 const arrayBuffer = new Uint8Array(length); 25 let pos = 0; 26 for (const buffer of data) { 27 arrayBuffer.set(buffer, pos); 28 pos += buffer.byteLength; 29 } 30 await loadSegment(sb, arrayBuffer); 31 // Since we are passing multiple segments in one buffer, 32 // the first durationchange event from parsing the init 33 // segment will be fired before updateend. 34 const p = once(v, "durationchange"); 35 ms.endOfStream(); 36 await p; 37 ok(v.duration, 1.601666); 38 SimpleTest.finish(); 39 }); 40 41 </script> 42 </pre> 43 </body> 44 </html>