Does anyone know how to play sounds with JavaScript, for example I want to play this sound sounds/main.mp3
.
Asked
Active
Viewed 1,117 times
0

Eddie Domingues
- 43
- 1
- 6
1 Answers
1
Start by defining your audio file.
Then you can call it where you want in your scripts with play().
var myAudio = new Audio('sounds/main.mp3');
myAudio.play();

Louys Patrice Bessette
- 33,375
- 6
- 36
- 64