test_FrameSelection_mp4.html (2000B)
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 // This test loads partial video, plays and waits until playback stalls. 15 // It then loads only 3 frames of a video at higher resolution. 16 17 runWithMSE(async (ms, v) => { 18 await once(ms, "sourceopen"); 19 ok(true, "Receive a sourceopen event"); 20 ms.addEventListener("sourceopen", () => ok(false, "No more sourceopen")); 21 const sb = ms.addSourceBuffer("video/mp4"); 22 ok(sb, "Create a SourceBuffer"); 23 logEvents(v); 24 sb.addEventListener("error", e => { 25 ok(false, `should not fire ${e.type} event`); 26 SimpleTest.finish(); 27 }); 28 await fetchAndLoad(sb, "bipbop/bipbop", ["init"], ".mp4"); 29 const p = once(v, "loadeddata"); 30 await fetchAndLoad(sb, "bipbop/bipbop", range(1, 3), ".m4s"); 31 await p; 32 is(sb.buffered.length, 1, "continuous range"); 33 v.play(); 34 // We have nothing to play, waiting will be fired. 35 await waitUntilTime(v, 1.5); 36 await fetchAndLoad(sb, "bipbop/bipbop_480_624kbps-video", ["init"], ".mp4"); 37 sb.timestampOffset = 1.601666; // End of the video track buffered - time of first video sample (0.095). 38 sb.appendWindowEnd = 1.796677; // Only allow room for three extra video frames (we need 3 as this video has b-frames). 39 await fetchAndLoad(sb, "bipbop/bipbop_480_624kbps-video", ["1"], ".m4s"); 40 ms.endOfStream(); 41 await Promise.all([once(ms, "sourceended"), once(v, "playing"), once(v, "ended")]); 42 is(v.videoWidth, 640, "has proper width"); 43 is(v.videoHeight, 480, "has proper height"); 44 SimpleTest.finish(); 45 }); 46 </script> 47 </pre> 48 </body> 49 </html>