mediasource-h264-play-starved.html (1980B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>Test MediaSource behavior when the decoder is starved.</title> 5 <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> 6 <meta name="timeout" content="long"> 7 <link rel="author" title="Alicia Boya GarcĂa" href="mailto:aboya@igalia.com"/> 8 <script src="/resources/testharness.js"></script> 9 <script src="/resources/testharnessreport.js"></script> 10 <script src="mediasource-util.js"></script> 11 </head> 12 <body> 13 <div id="log"></div> 14 <script> 15 mediasource_test(function (test, video, mediaSource) { 16 if (!MediaSource.isTypeSupported('video/mp4; codecs="avc1.4d001e"')) { 17 // Format not supported, nothing to test in this platform. 18 test.done(); 19 return; 20 } 21 22 let initSegment; 23 let mediaSegment; 24 25 const videoSB = mediaSource.addSourceBuffer('video/mp4; codecs="avc1.4d001e"'); 26 27 MediaSourceUtil.loadBinaryData(test, "mp4/h264-starvation-init.mp4", initDownloaded); 28 29 function initDownloaded(data) { 30 initSegment = data; 31 MediaSourceUtil.loadBinaryData(test, "mp4/h264-starvation-media.mp4", mediaDownloaded); 32 } 33 34 function mediaDownloaded(data) { 35 mediaSegment = data; 36 videoSB.appendBuffer(initSegment); 37 videoSB.addEventListener("updateend", initSegmentAppended); 38 } 39 40 function initSegmentAppended() { 41 videoSB.removeEventListener("updateend", initSegmentAppended); 42 videoSB.appendBuffer(mediaSegment); 43 videoSB.addEventListener("updateend", mediaSegmentAppended) 44 } 45 46 function mediaSegmentAppended() { 47 video.play(); 48 49 video.addEventListener('timeupdate', function onTimeUpdate() { 50 if (video.currentTime >= 2) 51 test.done(); 52 }); 53 } 54 }, "Enough frames are played when the decoder is starved.") 55 </script> 56 </body> 57 </html>