See title. I am trying to play an audio file 4 times in a row, every 300 milliseconds. However, the clip is longer than 300ms, so it ignores new play requests until the clip is done playing. I'm looking for some way to stop and restart the clip every 300ms.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
</head>
<body>
<audio id="note0440"><source src="0440.a4.wav" type="audio/wav"></audio>
<script type="text/javascript">
function playNote (loop) {
var n = document.getElementById("note0440")
if (loop > 4)
return
n.volume = 0.05
// n.currentTime = 0
n.pause()
n.play()
setTimeout("playNote("+(loop + 1)+")", 300)
}
</script>
<div style="margin:50px"><button onclick="playNote(1)">Play Note</button></div>
</body>
</html>
This does not work. It does not stop and restart, whether or not n.currentTime = 0
is used.
Here's a WAV file if you need one for testing: http://popstrip.com/misc/0440.a4.wav