Play full HTML5 video and then loop a section of it

后端 未结 5 1134
不知归路
不知归路 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 16:04

    You can't solve this issue in javascript. That delay you see depends on the video compression and the hardware.

    To start playing at a time that is not 0, the video decoder has to go back and find a key frame and then build the current frame by reading everything between the last key frame and your chosen time.

    I'm not an expert in video compression, but maybe there is a way to pick these key frames and place them exactly where you need them. I don't think it will be easy and smooth, though.


    If you're looking for an easier solution, use @Random's, but it uses two tags to work around this limit.

提交回复
热议问题