'jquery Audio don't repeat

I would like to repeat an audio file with 5 seconds length for example 10 times.

var audioElement = document.createElement('audio');
audioElement.setAttribute('src', 'sounds/test.mp3');
$('#play').click(function() {
    audioElement.play();
});

That is working fine. See fiddle: https://jsfiddle.net/cpmrqn4s/11/

But: My app replay automatically the sound but with a small gap between. So you have milliseconds without sound.

So 2 questions:

  1. How can I stop the auto repeat?

  2. And how can I make a loop of 10 times without a sound gap?

Thank you!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source