<h1>Manual &lt;audio&gt; loop</h1>
<div style="align: center">
    <audio id="myAudio" src="https://romgerebox.mestres.fr/samples/test.mp3"></audio>
  <br />
  <a href="javascript:play()">Play</a>
  &nbsp;|&nbsp;
  <a href="javascript:stop()">Stop</a>
</div>
var audio = document.getElementById('myAudio');
var loopTime = 5333;
var intervalId = null;

function play(){  
  intervalId = setInterval(doLoop, loopTime);
  audio.play();
  audio.currentTime = 0;
}

function stop(){  
  audio.currentTime = 0;
  audio.pause();
  clearInterval(intervalId);
}

function doLoop(){
  audio.currentTime = 0;  
}
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.