title: play multiple videos for different time duration?
body: <p>I am creating a page with multiple videos slide show(video playinf one by one correctly). But now I want to add time duration to each video.</p>
  
  <p>I have a four videos(array in javascript) and I want to play first video(2mins video)for 15mins and second(10mins) video for 30mins and so on. Please tell me guys, how to do it?</p>
  
  <p>//my code</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>//multiple video playing code
  var videoSource = new Array();
  videoSource[0] = 'Colgate.mp4';
  videoSource[1] = 'Soap.mp4';
  var i = 0;
  var videoCount = videoSource.length;
  //document.getElementById("myVideo").setAttribute("src",videoSource[0]);
  function videoPlay(videoNum) {
    document.getElementById("myVideo").setAttribute("src", videoSource[videoNum]);
    document.getElementById("myVideo").load();
    document.getElementById("myVideo").play();
  }
  document.getElementById('myVideo').addEventListener('ended', myHandler, false);
  videoPlay(1);
  
  function myHandler() {
    i++;
    if (i == (videoCount - 1)) {
      i = 0;
      videoPlay(i);
    } else {
      videoPlay(i);
    }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org" version="VideoLAN.VLCPlugin.2" width="100%" height="auto" id="vlc" loop="yes" autoplay="yes"&gt;&lt;/embed&gt;
  &lt;center&gt;&lt;video controls autoplay id="myVideo" width="100%" height="auto"&gt;&lt;/video&gt;&lt;/center&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>My javascript code for one video timing is working.</p>
  
  <p>var video = document.getElementById('myVideo');</p>
  
  <pre><code>var videoStartTime = 0;
  var durationTime = 0;
  
  video.addEventListener('loadedmetadata', function() {
    videoStartTime = 20;
    durationTime = 22;
    this.currentTime = videoStartTime;
  }, false);
  video.addEventListener('timeupdate', function() {
    if(this.currentTime &gt; videoStartTime + durationTime){
      this.pause();
    }
  });
  </code></pre>