Using JavaScript to stop a looping video at specific time

I have a video that loops twice. On the second loop I want the video to stop at 8 seconds.

Am I missing something or am I making this more complicated than it is?

This is what I have tried so far:

<!DOCTYPE html> 
<html> 
<body> 

<p>Press play and wait for the video to end.</p>
<div>Iteration: <span id="iteration"></span></div>
<video autoplay id="myVideo" width="320" height="176" controls>
  <source src="mov_bbb.mp4" type="video/mp4">
  <source src="mov_bbb.ogg" type="video/ogg">
  Your browser does not support HTML5 video.
</video>

<script>
var iterations = 1;

document.getElementById('iteration').innerText = iterations;

myVideo.addEventListener('ended', function () {    

    if (iterations < 2) {       

        this.currentTime = 0;
        this.play();
        iterations ++;

        document.getElementById('iteration').innerText = iterations;

    }   

}, false);
</script>

<script>


video.addEventListener('timeupdate', function () {
    if (mediaPlayer.currentTime > stopframes[0]) {
        ...
    }
});



</script>
<p>Video courtesy of <a href="https://www.bigbuckbunny.org/" target="_blank">Big Buck Bunny</a>.</p>

</body> 
</html>