Hi I need to loop audio file a certain number of times ie 4, I have the sound file looping correctly, code below. ? how to stop loop after 4x, many thanks P
I managed to do it like this:
$('#play_audio').click(function () {
var times = 4;
var loop = setInterval(repeat, 500);
function repeat() {
times--;
if (times === 0) {
clearInterval(loop);
}
var audio = document.createElement("audio");
audio.src = "files/windows%20default.mp3";
audio.play();
}
repeat();
});
});