jeudi 19 octobre 2017

Delay in JavaScript audio playback

I am writing a very simple game in JavaScript and I notice that there is about a 0.5 seconds delay from the time that I call the "play" function to the time the audio starts playing. Is this normal?

This is the code I have:

var audio = new Audio("games/aventura4/sfx/hit.wav");
audio.play();

I have also tried initializing the audio variable only once, and then just calling audio.play() (after doing audio.currentTime = 0, of course), and the delay is still there!

Am I doing anything wrong? (I'm trying this on Safari, btw).




Aucun commentaire:

Enregistrer un commentaire