0

so trying to do functionality of looping video in needed timeline. For example I have a video in total 20 seconds, I want to take 5 middle seconds of this video and just loop over them. I've tried to search how to do it in google and stackoverflow, but didn't find any solution. Is it even possible?

  • It's called `A-B looping` to loop media between two points. Do you have an **event listener** for detecting the video's current time? If no, then it's not possible. If yes, then use it to detect if (or when) the video time is at point B then just seek back to point A and play again (this will cause a loop between A and B time points). – VC.One Oct 13 '22 at 09:21
  • Hmm, thanks, and can you please provide an example of it? Or any links that would be helpful, will appreciate it! – Roman Telyatnik Oct 13 '22 at 13:47
  • I don't use ReactJS (only normal JS) so maybe [this tutorial](https://www.createit.com/blog/audio-in-react-display-current-time/) will help you. The event listener you want to add is `onTimeUpdate={(event) => {timeUpdate(event)} }` where in that **timeUpdate** function you use `event.target.currentTime` to know what time your (video) player is currently showing. Also use an `IF` to check if the video time (seconds) is equal or above your **point-B** time, if yes then set **currentTime** to **point-A** time. – VC.One Oct 13 '22 at 19:11

0 Answers0