test_WaitingToEndedTransition_mp4.html (2113B)
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 const audiosb = ms.addSourceBuffer("audio/mp4"); 19 const videosb = ms.addSourceBuffer("video/mp4"); 20 // ensure tracks end at approximately the same time to ensure ended event is 21 // always fired (bug 1233639). 22 audiosb.appendWindowEnd = 3.9; 23 videosb.appendWindowEnd = 3.9; 24 await fetchAndLoad(audiosb, "bipbop/bipbop_audio", ["init"], ".mp4"); 25 await fetchAndLoad(videosb, "bipbop/bipbop_video", ["init"], ".mp4"); 26 await fetchAndLoad(audiosb, "bipbop/bipbop_audio", range(1, 5), ".m4s"); 27 await fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 6), ".m4s"); 28 // HTMLMediaElement fires "waiting" if somebody invokes |play()| before the MDSM 29 // has notified it of available data. Make sure that we get "playing" before 30 // we starting waiting for "waiting". 31 info("Invoking play()"); 32 let p = once(el, "playing"); 33 el.play(); 34 await p; 35 ok(true, "Video playing. It should play for a bit, then fire 'waiting'"); 36 await once(el, "waiting"); 37 p = once(el, "ended"); 38 ms.endOfStream(); 39 await p; 40 // Following bug 1524890, we now implement fully step 8 of the coded frame 41 // processing algorithm 42 // http://w3c.github.io/media-source/index.html#sourcebuffer-coded-frame-processing 43 // As such, duration is exactly the value of videosb.appendWindowEnd 44 is(el.duration, videosb.appendWindowEnd, "Video has correct duration: " + el.duration); 45 is(el.currentTime, el.duration, "Video has correct currentTime."); 46 SimpleTest.finish(); 47 }); 48 49 </script> 50 </pre> 51 </body> 52 </html>