1<html> 2<body> 3 <video id='video' name='media' height="480" width="854"> 4 <source src='' type='video'> 5 </video> 6 <br> 7Current time (seconds): <span id='videoCurTime'>0</span> 8</body> 9 10<script type="text/javascript"> 11var can_play = false; 12var script_ready = false; 13var finished_seeking = false; 14var error_status = false; 15var video_ended = false; 16 17(function() { 18 var timeEle = document.getElementById('videoCurTime'); 19 video.addEventListener('timeupdate', function(event) { 20 timeEle.innerHTML = video.currentTime; 21 }, false); 22})(); 23 24(function() { 25 video.addEventListener('canplay', function(event) { 26 can_play = true; 27 }, false); 28})(); 29 30(function() { 31 video.addEventListener('error', function(event) { 32 error_status = true; 33 }, false); 34})(); 35 36(function() { 37 video.addEventListener('seeked', function(event) { 38 finished_seeking = true; 39 }, false); 40})(); 41 42(function() { 43 video.addEventListener('seeking', function(event) { 44 finished_seeking = false; 45 }, false); 46})(); 47 48(function() { 49 video.addEventListener('ended', function(event) { 50 video_ended = true; 51 }, false); 52})(); 53 54 55 56function loadVideoSource(video_source_path) { 57 video.src = video_source_path; 58 return true; 59} 60 61function canplay() { 62 return can_play; 63} 64 65function finishedSeeking() { 66 return finished_seeking; 67} 68 69function play() { 70 video.play(); 71} 72 73function pause() { 74 video.pause(); 75} 76 77function currentTime() { 78 return video.currentTime; 79} 80 81function errorDetected() { 82 return error_status; 83} 84 85function endOrError() { 86 return video_ended || error_status; 87} 88 89 90function setControls() { 91 video.setAttribute("controls","true"); 92} 93script_ready = true; 94</script> 95</html> 96