OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <script src=media-file.js></script> |
| 5 <script src=video-test.js></script> |
| 6 <script> |
| 7 var seekCount = 0; |
| 8 var expectedSeek = 0; |
| 9 var video; |
| 10 |
| 11 function seeking(e) |
| 12 { |
| 13 consoleWrite("seeking " + e.target.currentTime.toFixed(2)); |
| 14 |
| 15 doNextSeek(e.target); |
| 16 } |
| 17 |
| 18 function seeked(e) |
| 19 { |
| 20 consoleWrite("seeked " + e.target.currentTime.toFixed(2)); |
| 21 |
| 22 video = e.target; |
| 23 var now = e.target.currentTime.toFixed(2); |
| 24 var expected = expectedSeek.toFixed(2); |
| 25 if (now != expected) { |
| 26 failTest("Expected " + expectedSeek + " got " + now); |
| 27 return; |
| 28 } |
| 29 endTest(); |
| 30 } |
| 31 |
| 32 function doNextSeek(video) |
| 33 { |
| 34 consoleWrite("doNextSeek() " + seekCount); |
| 35 |
| 36 var newSeekPoint = -1; |
| 37 switch (seekCount) { |
| 38 case 0: |
| 39 newSeekPoint = 1; |
| 40 break; |
| 41 case 1: |
| 42 newSeekPoint = 1.5; |
| 43 break; |
| 44 case 2: |
| 45 newSeekPoint = 1.5; |
| 46 break; |
| 47 }; |
| 48 |
| 49 if (newSeekPoint >= 0) { |
| 50 consoleWrite('doNextSeek() seeking to ' + newSeekPoint.toFix
ed(2)); |
| 51 expectedSeek = newSeekPoint; |
| 52 video.currentTime = newSeekPoint; |
| 53 } |
| 54 seekCount++; |
| 55 } |
| 56 |
| 57 function loadedmetadata(e) |
| 58 { |
| 59 consoleWrite("loadedmetadata()"); |
| 60 doNextSeek(e.target); |
| 61 } |
| 62 |
| 63 function onWindowLoad(e) |
| 64 { |
| 65 video = document.getElementById('video'); |
| 66 |
| 67 video.src = findMediaFile("video", "content/test"); |
| 68 video.addEventListener('seeking', seeking); |
| 69 video.addEventListener('seeked', seeked); |
| 70 video.addEventListener('loadedmetadata', loadedmetadata); |
| 71 video.load(); |
| 72 } |
| 73 |
| 74 window.addEventListener('load', onWindowLoad, false); |
| 75 </script> |
| 76 </head> |
| 77 <body> |
| 78 <video controls id="video"></video> |
| 79 <p>Test currentTime values when setting from seeking event.</p> |
| 80 <br/> |
| 81 </body> |
| 82 </html> |
OLD | NEW |