使用JavaScript在特定时间停止循环播放视频

我有一个循环播放两次的视频。 在第二个循环中,我希望视频在8秒后停止。

我错过了什么吗?还是使事情变得比原来更复杂?

这是我到目前为止尝试过的:

<!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>
renbogoushi 回答:使用JavaScript在特定时间停止循环播放视频

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3137544.html

大家都在问