Does anyone know how to play sounds with JavaScript, for example I want to play this sound sounds/main.mp3.
Asked
Active
Viewed 1,027 times
0
Eddie Domingues
- 43
- 1
- 6
-
2Possible duplicate of [Playing audio with Javascript?](http://stackoverflow.com/questions/9419263/playing-audio-with-javascript) – Michał Perłakowski May 21 '16 at 00:03
-
@ Gothdo, Definitively! ;) – Louys Patrice Bessette May 21 '16 at 00:04
1 Answers
0
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
- 31,534
- 6
- 35
- 61