If the loop is 10s long, then it only starts playing 10s after recordStop. This is because window.setInterval doesn't run the function immediately, but rather only after interval.
So I would recommend changing recordStop to have:
if (data.length) {
loopInterval = window.setInterval(playLoop, totalTime, data);
playLoop(data);
}
and remove the setInterval logic from playLoop, so that the loop is played as soon as the recording is stopped.
If the loop is 10s long, then it only starts playing 10s after
recordStop. This is becausewindow.setIntervaldoesn't run the function immediately, but rather only after interval.So I would recommend changing recordStop to have:
and remove the
setIntervallogic fromplayLoop, so that the loop is played as soon as the recording is stopped.