1 <!-- This is a test html file for video test. --> 2 <html> 3 <body> 4 <video id='testvideo' controls autoplay muted name='media'> 5 <source src=''> 6 </video> 7 </body> 8 9 <script type="text/javascript"> 10 var NUM_FAST_SEEKS = 16; 11 var NUM_SEEKS = 100; 12 13 var fast_seeks = 0; 14 var seeks = 0; 15 16 var testvideo = document.getElementById('testvideo'); 17 18 function loadSourceAndRunSeekTest(video) { 19 testvideo.src = video; 20 testvideo.play(); 21 22 // Random seek forward and backward until reaching NUM_SEEKS. 23 // The next seek will be immediately tirggered after getting the "seeking" 24 // event for NUM_FAST_SEEKS times. After that, we will wait for the "seeked" 25 // event and repeat for NUM_SEEKS times. 26 fast_seeks = 0; 27 seeks = 0; 28 testvideo.addEventListener('seeking', function() { 29 fast_seeks++; 30 if (fast_seeks < NUM_FAST_SEEKS) 31 randomSeek(); 32 }); 33 34 testvideo.addEventListener('seeked', function() { 35 seeks++; 36 fast_seeks = 0; 37 if (seeks < NUM_SEEKS) 38 randomSeek(); 39 }); 40 41 // Start the first seek only after the video is ready. 42 testvideo.addEventListener("loadeddata", function() { randomSeek(); }); 43 } 44 45 function randomSeek() { 46 testvideo.currentTime = Math.random() * testvideo.duration; 47 } 48 49 function getSeekTestStatus() { 50 if (seeks == NUM_SEEKS) 51 return 'pass' 52 53 return testvideo.currentTime + '/' + testvideo.duration + '/' + seeks; 54 } 55 </script> 56 </html> 57