I have built a recorder with timer of 15 seconds which works fine on start and stop. But when we pause the recording, the recording pauses but the timer deducts another 1 second before stopping.
Following is the js code where I am doing this stuff of getting the recorder state and doing clearInterval(countDown) in it.
p.s I have also tried putting timeSecond inside else
const countDown = setInterval(() => {
displayTime(timeSecond);
if (timeSecond == 0 || timeSecond < 1) {
endCount();
clearInterval(countDown);
}
if (recorder && recorder.state === 'paused') {
clearInterval(countDown)
}
else{
timeSecond--;
}
}, 1000);
const countDown = setInterval(() => {
displayTime(timeSecond);
if (timeSecond == 0 || timeSecond < 1) {
endCount();
clearInterval(countDown);
}
if (recorder && recorder.state === 'paused') {
clearInterval(countDown)
}
timeSecond--;
}, 1000);