Advertisement
Guest User

player html5

a guest
Mar 14th, 2012
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.19 KB | None | 0 0
  1. <!DOCTYPE html>
  2.  
  3. <html>
  4.  
  5.     <head>
  6.  
  7.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  8.  
  9.        
  10.         <title>html5video</title>
  11.  
  12.  
  13.         <link rel="stylesheet" type="text/css" href="html5v2.css">
  14.        
  15.     </head>
  16.  
  17. <body>  
  18.  
  19.  
  20.  
  21.  
  22. <video autoplay id="video">
  23.     <source src="movies/39steps_mit_subs.webm">
  24.     I just can't :(
  25. </video>
  26.  
  27.  
  28. <script>
  29.  
  30. var video = document.getElementsById('video');
  31.  
  32.  
  33. video.onpause = video.onplay = function(e) {
  34.   playpause.value = video.paused ? 'Play' : 'Pause';
  35. }
  36. function playOrPause() {
  37.   if (video.ended || video.paused) {
  38.     video.play();
  39.   } else {
  40.     video.pause();
  41.   }
  42. }
  43.  
  44.  
  45. var seekbar = document.getElementById('seekbar');
  46. function setupSeekbar() {
  47.   seekbar.min = video.startTime;
  48.   seekbar.max = video.startTime + video.duration;
  49. }
  50. video.ondurationchange = setupSeekbar;
  51.  
  52. function seekVideo() {
  53.   video.currentTime = seekbar.value;
  54. }
  55. function updateUI() {
  56.   seekbar.value = video.currentTime;
  57. }
  58. seekbar.onchange = seekVideo;
  59. video.ontimeupdate = updateUI;
  60.  
  61. </script>
  62.  
  63. <input type="button" value="Play" id="playpause" onclick="playOrPause()">
  64. <input type="range" step="any" id="seekbar">
  65.  
  66. </body>
  67. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement