With HTML5 If you are using HTML5, use the loop attribute.
<audio controls loop> <source src="horse.ogg" type="audio/ogg"> <source src="horse.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio>
It does not create a space, checks your audio file, most of the audio file has a gap at the end.
You can test it here , just add the loop attribute and start the page.
With javascript
There is also an alternative here using javascript
myAudio = new Audio('someSound.ogg'); myAudio.addEventListener('ended', function() { this.currentTime = 0; this.play(); }, false); myAudio.play();
Here, JavaScript will create a small gap, you can overcome it by playing in a loop when the sound is not finished, but when the sound is about to end. Here is the code.
Here is what you want.
myAudio = new Audio('http://unska.com/audio/pinknoise.ogg'); myAudio.ontimeupdate= function(i) { if((this.currentTime / this.duration)>0.9){ this.currentTime = 0; this.play(); } }; myAudio.play();
There is a demo here.
Laxmikant dange
source share