test_BufferingWait_mp4.html (1930B)
1 <!DOCTYPE html> 2 <html><head> 3 <meta http-equiv="content-type" content="text/html; charset=windows-1252"> 4 <title>MSE: Don't get stuck buffering for too long when we have frames to show</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"><script class="testbody" type="text/javascript"> 11 12 SimpleTest.waitForExplicitFinish(); 13 14 runWithMSE(async (ms, v) => { 15 await once(ms, "sourceopen"); 16 ok(true, "Receive a sourceopen event"); 17 ms.addEventListener("sourceopen", () => ok(false, "No more sourceopen")); 18 const sb = ms.addSourceBuffer("video/mp4"); 19 ok(sb, "Create a SourceBuffer"); 20 21 sb.addEventListener("error", e => { 22 ok(false, "Got Error: " + e); 23 SimpleTest.finish(); 24 }); 25 await fetchAndLoad(sb, "bipbop/bipbop", ["init"], ".mp4"); 26 await fetchAndLoad(sb, "bipbop/bipbop", ["1"], ".m4s"); 27 await fetchAndLoad(sb, "bipbop/bipbop", ["2"], ".m4s"); 28 /* Note - Missing |bipbop3| segment here corresponding to (1.62, 2.41] */ 29 /* Note - Missing |bipbop4| segment here corresponding to (2.41, 3.20] */ 30 await fetchAndLoad(sb, "bipbop/bipbop", ["5"], ".m4s"); 31 // last audio sample has a start time of 1.578956s 32 info("Playing video. It should play for a bit, then fire 'waiting'"); 33 v.play(); 34 await waitUntilTime(v, 1.57895); 35 const firstStop = Date.now(); 36 await fetchAndLoad(sb, "bipbop/bipbop", ["3"], ".m4s"); 37 // last audio sample has a start time of 2.368435 38 await waitUntilTime(v, 2.36843); 39 const waitDuration = (Date.now() - firstStop) / 1000; 40 ok(waitDuration < 15, `Should not spend inordinate amount of time buffering: ${waitDuration}`); 41 await fetchAndLoad(sb, "bipbop/bipbop", ["4"], ".m4s"); 42 ms.endOfStream(); 43 await once(v, "ended"); 44 SimpleTest.finish(); 45 }); 46 </script> 47 </pre> 48 </body> 49 </html>