Make HTML5 video stop at indicated time

后端 未结 4 1325
太阳男子
太阳男子 2021-02-07 07:45

I have a HTML5 video element in my page. The video I want to play is having a duration of 10 minutes.

I have to play the part of the video from minute

4条回答
  •  忘掉有多难
    2021-02-07 08:10

    Not sure of an inbuilt way, but one way would be to use the setInterval Function and check the currentTime for the video and then stop playback

    var myVid=document.getElementById("video1");
    var timer= setInterval(function(){myTimer()},1000);
    function myTimer()
      {
        if(myVid.currentTime == 5* 60)
        {
           myVid.pause();
           window.clearInterval(timer);
        }
      }
    

提交回复
热议问题