Audio in JS not working
neodymium (27)

I'm trying to play audio by doing this:

var audio = new Audio("sound.mp3");
audio.play();

I am getting a little click on my speakers but the sound is not playing. Is there another way of doing this?

You are viewing a single comment. View All
ArchieMaclean (613)

do you have a link to a repl?

locness3 (13)

@neodymium Make sure your browser doesn't block audio autoplay, I allowed it and it worked for me. Also check the console.

locness3 (13)

@neodymium BTW commenting in CSS doesn't work with // like you did somewhere