avinash kodipelli | 9704379 | 2016-01-05 14:36:50 -0800 | [diff] [blame] | 1 | <html> |
| 2 | <body> |
Mussa | 83a3d08 | 2016-03-14 14:55:16 -0700 | [diff] [blame] | 3 | <video id='video' name='media' height="480" width="854"> |
avinash kodipelli | 9704379 | 2016-01-05 14:36:50 -0800 | [diff] [blame] | 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; |
avinash kodipelli | 6c756ed | 2016-01-27 12:12:08 -0800 | [diff] [blame] | 12 | var script_ready = false; |
avinash kodipelli | 9704379 | 2016-01-05 14:36:50 -0800 | [diff] [blame] | 13 | var finished_seeking = false; |
avinash kodipelli | a0d3321 | 2016-01-13 10:36:22 -0800 | [diff] [blame] | 14 | var error_status = false; |
Hirokazu Honda | 2d1a58a | 2017-04-24 13:33:01 +0900 | [diff] [blame] | 15 | var video_ended = false; |
avinash kodipelli | 9704379 | 2016-01-05 14:36:50 -0800 | [diff] [blame] | 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() { |
Mussa | b0eea2a | 2016-02-01 17:21:39 -0800 | [diff] [blame] | 25 | video.addEventListener('canplay', function(event) { |
avinash kodipelli | 9704379 | 2016-01-05 14:36:50 -0800 | [diff] [blame] | 26 | can_play = true; |
| 27 | }, false); |
| 28 | })(); |
| 29 | |
| 30 | (function() { |
avinash kodipelli | a0d3321 | 2016-01-13 10:36:22 -0800 | [diff] [blame] | 31 | video.addEventListener('error', function(event) { |
| 32 | error_status = true; |
| 33 | }, false); |
| 34 | })(); |
| 35 | |
| 36 | (function() { |
avinash kodipelli | 9704379 | 2016-01-05 14:36:50 -0800 | [diff] [blame] | 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 | |
Hirokazu Honda | 2d1a58a | 2017-04-24 13:33:01 +0900 | [diff] [blame] | 48 | (function() { |
| 49 | video.addEventListener('ended', function(event) { |
| 50 | video_ended = true; |
| 51 | }, false); |
| 52 | })(); |
| 53 | |
| 54 | |
| 55 | |
avinash kodipelli | 9704379 | 2016-01-05 14:36:50 -0800 | [diff] [blame] | 56 | function loadVideoSource(video_source_path) { |
| 57 | video.src = video_source_path; |
| 58 | return true; |
| 59 | } |
| 60 | |
| 61 | function canplay() { |
| 62 | return can_play; |
| 63 | } |
| 64 | |
| 65 | function finishedSeeking() { |
| 66 | return finished_seeking; |
| 67 | } |
| 68 | |
| 69 | function play() { |
| 70 | video.play(); |
| 71 | } |
| 72 | |
| 73 | function pause() { |
| 74 | video.pause(); |
| 75 | } |
| 76 | |
| 77 | function currentTime() { |
| 78 | return video.currentTime; |
| 79 | } |
avinash kodipelli | a0d3321 | 2016-01-13 10:36:22 -0800 | [diff] [blame] | 80 | |
| 81 | function errorDetected() { |
| 82 | return error_status; |
| 83 | } |
avinash kodipelli | d81b422 | 2016-07-26 10:27:14 -0700 | [diff] [blame] | 84 | |
Hirokazu Honda | 2d1a58a | 2017-04-24 13:33:01 +0900 | [diff] [blame] | 85 | function endOrError() { |
| 86 | return video_ended || error_status; |
| 87 | } |
| 88 | |
| 89 | |
avinash kodipelli | d81b422 | 2016-07-26 10:27:14 -0700 | [diff] [blame] | 90 | function setControls() { |
| 91 | video.setAttribute("controls","true"); |
| 92 | } |
avinash kodipelli | 6c756ed | 2016-01-27 12:12:08 -0800 | [diff] [blame] | 93 | script_ready = true; |
avinash kodipelli | 9704379 | 2016-01-05 14:36:50 -0800 | [diff] [blame] | 94 | </script> |
| 95 | </html> |