1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<!DOCTYPE html>
<html>
<head>
<title>Matt's awesome!!! video player</title>
<script>
   function play() {
     var play = document.getElementById("playButton");
     play.textContent ="Pause";
   }
   function pause() {
     var play = document.getElementById("playButton");
     play.textContent ="Play";
   }
   function playAndPause()
   {
     var v = document.getElementById("vid");

     if (v.paused)
     {
        v.play();
     } else {
        v.pause();
     }

   }
  function init()
  {
     var v = document.getElementById("vid");
     v.addEventListener("play", play, false);
     v.addEventListener("pause", pause, false);
     v.addEventListener("ended", pause, false);

     var b = document.getElementById("playButton");
     b.addEventListener("click", playAndPause, false);
  }

</script>
</head>
<body onload="init()">

 <video id="vid" src="octopus.ogv"
              width="360" height="240"></video>

 <p><button id="playButton" >Play</button></p>
</body>
</html>