test_WaitingOnMissingDataEnded_mp4.html (1907B)
1 <!DOCTYPE html> 2 <html><head> 3 <meta http-equiv="content-type" content="text/html; charset=windows-1252"> 4 <title>MSE: |waiting| event when source data is missing</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, el) => { 15 el.controls = true; 16 await once(ms, "sourceopen"); 17 ok(true, "Receive a sourceopen event"); 18 el.addEventListener("ended", () => { 19 ok(false, "ended should never fire"); 20 SimpleTest.finish(); 21 }); 22 const videosb = ms.addSourceBuffer("video/mp4"); 23 await fetchAndLoad(videosb, "bipbop/bipbop_video", ["init"], ".mp4"); 24 await fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 5), ".m4s"); 25 await fetchAndLoad(videosb, "bipbop/bipbop_video", range(6, 8), ".m4s"); 26 is(el.buffered.length, 2, "discontinuous buffered range"); 27 ms.endOfStream(); 28 await Promise.all([once(el, "durationchange"), once(ms, "sourceended")]); 29 // HTMLMediaElement fires "waiting" if somebody invokes |play()| before the MDSM 30 // has notified it of available data. Make sure that we get "playing" before 31 // we starting waiting for "waiting". 32 info("Invoking play()"); 33 el.play(); 34 await once(el, "playing"); 35 ok(true, "Video playing. It should play for a bit, then fire 'waiting'"); 36 await once(el, "waiting"); 37 // waiting is fired when we start to play the last frame. 38 // 0.033334 is the duration of the last frame, + 0.000001 of fuzz. 39 // the next video frame, currentTime can be up to 1 frame's worth earlier than end of video. 40 isfuzzy(el.currentTime, videosb.buffered.end(0), 0.033334, "waiting was fired on gap"); 41 SimpleTest.finish(); 42 }); 43 44 </script> 45 </pre> 46 </body> 47 </html>