Comment jouer un son sans interruption sans interruption?

J'essaie de jouer un son piloté par un véhicule dans un jeu basé sur le navigateur (sans interruption).
Ma longueur de fichier .wav est de 1 seconde et a la même fréquence du début à la fin. Mais le son prend une petite pause avant l'itération suivante.
Voici le code:

function playSound() { //alert(""); myAudio = new Audio('http://ithmbwp.com/feedback/SoundsTest/sounds/tank_driven.wav'); if (typeof myAudio.loop == 'boolean') { myAudio.loop = true; } else { myAudio.addEventListener('ended', function() { this.currentTime = 0; this.play(); }, false); } myAudio.volume = 0.3; myAudio.play(); } 

Quelqu'un peut-il m'aider à jouer le son de manière continue?

Édition

Vous pouvez visiter ma page ici pour observer le problème.

 window.onload = function() { playSound(); }; function playSound() { //alert(""); myAudio = new Audio('http://ithmbwp.com/feedback/SoundsTest/sounds/tank_driven.wav'); if (typeof myAudio.loop == 'boolean') { myAudio.loop = true; } else { myAudio.addEventListener('ended', function() { this.currentTime = 0; this.play(); }, false); } myAudio.volume = 0.3; myAudio.play(); } 
 <h3 style="font-family:verdana;">Please listen the sound break.</h3> <h3 style="font-family:verdana;">It should be continuous.</h3> 

Utilisez l'API AudioContext et son interface bufferSourceNode , pour avoir des sons en boucle transparente.

Notez que vous aurez également besoin de votre audio pour être correctement édité pour éviter les craquements et les clips sonores, mais le vôtre semble bon.

 const aCtx = new AudioContext(); let source = aCtx.createBufferSource(); let buf; fetch('https://dl.dropboxusercontent.com/s/knpo4d2yooe2u4h/tank_driven.wav') // can be XHR as well .then(resp => resp.arrayBuffer()) .then(buf => aCtx.decodeAudioData(buf)) // can be callback as well .then(decoded => { source.buffer = buf = decoded; source.loop = true; source.connect(aCtx.destination); check.disabled = false; }); check.onchange = e => { if (check.checked) { source.start(0); // start our bufferSource } else { source.stop(0); // this destroys the buffer source source = aCtx.createBufferSource(); // so we need to create a new one source.buffer = buf; source.loop = true; source.connect(aCtx.destination); } }; 
 <label>play audioBuffer</label> <input type="checkbox" id="check" disabled><br><br> Just to compare <audio src="https://dl.dropboxusercontent.com/s/knpo4d2yooe2u4h/tank_driven.wav" loop controls> 

Bee Cool, utilisez simplement quelques lignes de code

 window.onload = function() { playSound(); }; function playSound() { var myAudio = new Audio('http://ithmbwp.com/feedback/SoundsTest/sounds/tank_driven.wav'); myAudio.volume = 0.3 ; var tank_driven_sound = setInterval(function() { myAudio.currentTime = 0; myAudio.play(); }, 800); } 
 <h3 style="font-family:verdana;">Please listen, it's continuous.</h3>