I am looking for a way to check the IF statement every 1 second,
var vid = document.getElementById("video");
var cTime = vid.currentTime;
if ( cTime > 5 && cTime < 10) {
}
and once it is met, then run the code
vid.currentTime = 15
I have tried setInterval method but assume that it is memory leak. The other thing I tried is
var vid = document.getElementById("video");
var cTime = vid.currentTime;
function skip() {
if (cTime > 5 && cTime < 10) {
vid.currentTime = 15
}
setTimeout(skip, 1000);
}
but it keeps on firing the currentTime to 15. I might have multiple if statements in the future. What is the best way to do it?