title: How to stop looping an HTML5 video loop and let it play out to the end
body: <p>I have a video that I would like to loop. After N seconds I would like it to stop looping. It should not stop immediately when the timer expires, but proceed to the end of the video and then stop.</p>
  <p>This is my html code</p>
  <pre><code> &lt;video poster=&quot;images/banner-bg.jpg&quot; id=&quot;bgvid&quot; playsinline autoplay muted loop&gt;
      &lt;source src=&quot;vid/MM_Logo_Identity.mp4&quot; type=&quot;video/mp4&quot; id=&quot;bgvid1&quot;&gt;
      &lt;/video&gt;
  </code></pre>
  <p>script</p>
  <pre><code>document.getElementsByTagName('source').addEventListener('ended',myHandler,false);
  function myHandler(e) {
      console.log('ended');
      setTimeout(function(){
          document.getElementsByTagName('source').play();
      }, 9000);
  }; 
  </code></pre>