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).
Edit: after experimenting with this, it seems that the problem is just running this on Safari. There is no delay on Chrome. But that still leaves the question of why does it happen in Safari?!?!
Edit 2: it seems it might be related to this other question: HTML5 Audio tag on Safari has a delay