title: VideoJS - Seamless Looping Video
body: <p>New here and have a question for anyone experienced with HTML5 video and/or the VideoJS player (I'm also open to using a different player if necessary).</p>
  
  <p>I've got a single video which includes an intro portion and a portion which I'd like to loop. I've done this in order to prevent having a "black blip" when loading the second part of it.</p>
  
  <p>So my question is this, I'd like to have this second part seamlessly loop and can't seem to pull it off quite right. There seems to be a second or so as a delay before it begins playing again. I had my video editor set the looping point at exactly 36 seconds and am using the following code to seek to 36 seconds in and play after reaching the end.</p>
  
  <pre><code>myPlayer.addEvent("ended", function () {
    myPlayer.currentTime(36);
    myPlayer.play();
  });
  </code></pre>
  
  <p>This winds up swinging the video back to the first frame, then skipping to 36 seconds in, and then playing. I'm going to attempt setting a listener for the end second of the video and perform the seek, but I'm still concerned about the momentary delay after seeking.</p>
  
  <p>Any help would be greatly appreciated!</p>
  
  <p>Alex</p>
  
  <p>UPDATE: I've managed to eliminate the bit where it goes back to first frame by editing the source of video.js to remove the default functions run when the "ended" event gets triggered (which basically went like this: "pause(); currentTime(0); pause();" )</p>
  
  <p>The video will now go directly to the 36 second mark that I need it to, but the problem is that it still registers the video as ended and stops it before playing it again at the 36 second mark, creating a slight delay in the loop. I'm trying to figure out how I can get it to listen for, maybe, the second that the video is about to end and trigger the seek (currentTime) function then as opposed to the "ended" event listener.</p>