I was doing a research about the subject few months ago for play sound in a game, and SoundManager is the easier way to play audio using JavaScript.
First way:
If you go to the documentation, you will see that SoundManager intercepts clicks to MP3 links and plays them inline. The script assigns additional CSS classes to the links to indicate their state (playing/paused, etc.)
<a href="/mp3/foo.mp3" title="Play sound" class="sm2_button">Play Link</a>
Check demo and more info
Second way
If you want to use personalized buttons instead of links, or images, or any other html element, you can use the onClick
event to play/pause sound, for example:
Loading the sound:
<script>
soundManager.onready(function() {
soundManager.createSound({id:'mySound1',url:'/audio/foo.mp3'});
"
});
</script>
The buttons:
<button id="play" onclick="soundManager.play('mySound1');return false">Play Button</button>
<button id="pause" onclick="soundManager.pause('mySound1');return false">Pause Button</button>
You can found more info on the API