test_BufferingWait.html (2152B)
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/webm"); 19 ok(sb, "Create a SourceBuffer"); 20 21 const arrayBuffer = await fetchWithXHR("seek.webm"); 22 sb.addEventListener("error", e => { 23 ok(false, "Got Error: " + e); 24 SimpleTest.finish(); 25 }); 26 await loadSegment(sb, new Uint8Array(arrayBuffer, 0, 318)); 27 await loadSegment(sb, new Uint8Array(arrayBuffer, 318, 25523 - 318)); 28 await loadSegment(sb, new Uint8Array(arrayBuffer, 25523, 46712 - 25523)); 29 /* Note - Missing |46712, 67833 - 46712| segment here corresponding to (0.8, 1.2] */ 30 /* Note - Missing |67833, 88966 - 67833| segment here corresponding to (1.2, 1.6] */ 31 await loadSegment(sb, new Uint8Array(arrayBuffer, 88966)); 32 // 0.767 is the time of the last video sample +- 40ms. 33 info("Playing video. It should play for a bit, then fire 'waiting'"); 34 v.play(); 35 await waitUntilTime(v, .767 - 0.04); 36 const firstStop = Date.now(); 37 await loadSegment(sb, new Uint8Array(arrayBuffer, 46712, 67833 - 46712)); 38 await waitUntilTime(v, 1.167 - 0.04); 39 const waitDuration = (Date.now() - firstStop) / 1000; 40 ok(waitDuration < 15, `Should not spend inordinate amount of time buffering: ${waitDuration}`); 41 SimpleTest.finish(); 42 /* If we allow the rest of the stream to be played, we get stuck at 43 around 2s. See bug 1093133. 44 await once(v, "ended"); 45 SimpleTest.finish(); 46 await loadSegment(sb, new Uint8Array(arrayBuffer, 67833, 88966 - 67833)); 47 */ 48 }); 49 </script> 50 </pre> 51 </body> 52 </html>