Syncing Content With HTML5 Video

by Katie Donohoe

HTML

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">


<body>

<!--VIDEO 2 PART 2 -->
<div style="text-align:center">

    <h1>Part One: Grow</h1>

  <button onclick="playPause()">Play/Pause</button>
  <button onclick="nextButton()">Next</button>
  <br>
  <video id="videogrow" width="60%">
    <source src="http://fareireland.ie/mikethefrog.mp4" type="video/mp4">
    <source  type="video/mp3">
     <source type="video/ogg">
    Your browser does not support HTML5 video.
  </video>

  <!-- LEARN MORE-->
  <pre>
    <div hidden data-starttime=1 data-endtime=15 id="GrowLearnMore"><button type="button" class="GrowLearnGuide" data-toggle="modal" data-target="#GrowLearnModal" id="growLearn">Grow: Learn More</button></div>
  </pre><!-- Modal -->
    <div class="modal fade" id="GrowLearnModal" tabindex="-1" role="dialog" aria-labelledby="Grow: Learn More">
      <div class="modal-dialog" role="document">
        <!-- <div class="modal-content">-->
        <a href="http://www.nascireland.org/" target="blank"><img src="imgs/doMore.png" width ="250%" class="center" /></a><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
        <div class="closeButton1"><button type="button" class="GrowLearnGuide btn growLearn" data-dismiss="modal" id="growLearnClose">Back to Documentary X</button></div>
      </div><!--</modal>-->
    </div><!--</modal>-->
  <!-- END LEARN MORE-->
<!-- DO MORE-->
  <pre>
    <div hidden data-starttime=16 data-endtime=35 id="GrowDoMore"><button type="button" class="GrowDoGuide" data-toggle="modal" data-target="#GrowDoModal" id="growDo">Grow: Do More</button></div>
  </pre><!-- Modal -->
    <div class="modal fade" id="GrowDoModal" tabindex="-1" role="dialog" aria-labelledby="Grow: Do More">
      <div class="modal-dialog" role="document">
        <!-- <div class="modal-content">-->
        <a href="http://www.nascireland.org/" target="blank"><img src="imgs/doMore.png" width ="300%" class="center"...

CSS

.GrowLearnGuide
{
  width: 300px;
  position: relative;
  bottom: 190px;
  float:right;
  background-color: #ffc000;
  border-style: solid;
  z-index: 21474836;
}

.MakeLearnGuide
{
  width: 300px;
  position: relative;
  bottom: 190px;
  float:right;
  background-color: #ffc000;
  border-style: solid;
  z-index: 21474836;
}

  .GrowDoGuide
{
  width: 300px;
  position: relative;
  bottom: 190px;
  float:right;
  background-color: #ffcccc;
  border-style: solid;
  z-index: 21474837;
}

pre
{
  background-color: #2C2C2C;
  border: none;
  z-index: 2147483646;
}

.closeButton1
{
  font-family: 'Quicksand', sans-serif;
  font-size: 26pt;
  color: #000000;
  border: none;
  z-index: 2147483644;
  margin-left:820px;
  margin-top:-528px;
}

.closeButton2
{
  font-family: 'Quicksand', sans-serif;
  font-size: 26pt;
  color: #000000;
  border: none;
  z-index: 2147483644;
  margin-left:820px;
  margin-top:-528px;
}


button {
  background: rgba(0,0,0,.5);
  border: 0;
  color: #fff;
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  -o-border-radius: 3px;
  border-radius: 3px;
  width: 60px;
  height: 60px;
}


button:hover {
  cursor: pointer;
}

JavaScript

var growVideo=document.getElementById("videogrow");
var makeVideo=document.getElementById("videomake");
var videoList=['mikethefrog.mp4','mikethefrog.mp4'];
var index = videoList.indexOf(window.currentVideoName);
var growLearnButton = document.getElementById("growLearn");
var growLearnCloseButton = document.getElementById("growLearnClose");
var growDoButton = document.getElementById("growDo");
var growDoCloseButton = document.getElementById("growDoClose");
var makeLearnButton = document.getElementById("makeLearn");
var makeLearnCloseButton = document.getElementById("makeLearnClose");
var makeDoButton = document.getElementById("makeDo");
var makeDoCloseButton = document.getElementById("makeDoClose");


//Next button
function nextButton(){
growVideo.pause();
growVideo.currentTime=0;
index = index + 1;
if(index==videoList.length)
index = 0;
alert(videoList[index]);
growVideo.src = 'videos/'+videoList[index];
window.currentVideoName=videoList[index];
growVideo.play();
}
function playPause()
{
if (growVideo.paused)
  growVideo.play();
else
  growVideo.pause();
}


//DOC2
//Next button
function nextButton(){
makeVideo.pause();
makeVideo.currentTime=0;
index = index + 1;
if(index==videoList.length)
index = 0;
alert(videoList[index]);
makeVideo.src = 'videos/'+videoList[index];
window.currentVideoName=videoList[index];
makeVideo.play();
}
function playPause2()
{
if (makeVideo.paused)
  makeVideo.play();
else
  makeVideo.pause();
}

//GrowLearnMoreGuide


  // Event listener for the guide buttons
  growLearnButton.addEventListener("click", function() {
    if (growVideo.paused == true) {
      // Play the video
      growVideo.play();

      // Update the button text to 'Pause'
      growLearnButton.innerHTML = 'Grow: Learn More';
    } else {
      // Pause the video
      growVideo.pause();

      // Update the button text to 'Play'
      growLearnButton.innerHTML = 'Grow: Learn More';
    }
  });

  // Event listener for the close buttons
 ...