I am making a game with HTML5 and JavaScript.
How could I play game audio via JavaScript?
It's easy, just get your audio
element and call the play()
method:
document.getElementById('yourAudioTag').play();
Check out this example: http://www.storiesinflight.com/html5/audio.html
This site uncovers some of the other cool things you can do such as load()
, pause()
, and a few other properties of the audio
element.