Last active
March 26, 2020 18:00
-
-
Save RecuencoJones/763338ab3d98c9035589a65d62ccf59e to your computer and use it in GitHub Desktop.
Youtube Video Looper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function loop(video, loopStart, loopEnd) { | |
function _check() { | |
if (video.currentTime >= loopEnd) { | |
video.currentTime = loopStart; | |
} | |
} | |
const interval = window.setInterval(_check, 50); | |
return () => window.clearInterval(interval); | |
} | |
const video = document.querySelector('.html5-main-video'); | |
// loop one minute | |
// call stop() once done ;) | |
const stop = loop(video, 60, 120); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment