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