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