I got 2 function in my javascript interval:
I start the interval with 2 html buttons, start (starts it) and stop (stops it)
This is started:
function start_sync(){
//runs the interval
if(sync_interval == false)
{
sync_interval = setInterval(function(){
gl_context.drawImage(gl_video,0,0,gl_cw,gl_ch);
update_seek_slider_position(gl_video.currentTime);
},10);
sync_interval_running = true;
};
console.log("Sync Interval Started");
};
This is called when I press stop:
function stop_sync(){
if(sync_interval == true)
{
clearInterval(sync_interval); //stops the interval
sync_interval_running = false;
};
console.log("Sync Interval Stopped");
}
ok the thing is that, the second functions DOES NOT STOP, “update_seek_slider_position(gl_video.currentTime);”
it still goes one.
Does the js interval only accepts one function?
The following test is wrong so I guess the
clearIntervalfunction is never called:Replace it with:
The
sync_intervalvariable is returned by thesetIntervalfunction and is not a boolean value.Same remark for your
start_syncfunction. The test should be: