Play full HTML5 video and then loop a section of it

后端 未结 5 1142
不知归路
不知归路 2021-02-05 15:20

I\'m trying to play an 8.6 second video once completely, and then loop a small section of the video infinitely, to keep the illusion of a never-ending video. So far I\'ve looked

5条回答
  •  生来不讨喜
    2021-02-05 15:45

    Try the following, to 'rewind' it as soon as it ends:

    vidElem.addEventListener("ended", function () {
            vidElem.currentTime = 2.5;
            vidElem.play();
    }, false);
    

    Updated fiddle: http://jsfiddle.net/Lt4n7/1/

提交回复
热议问题