You could try SoundManager2
http://www.schillmania.com/projects/.../doc/download/
With it you can attach a javascript "Play()" event to anything (a div, a list item, a link, a button)
The SoundManager2 website styles dont seem to be working at the mo but download the software package and upload it to your server and view the documentation that comes with it there instead.
There are loads of examples under the Demo menu button - you just have to make sure you work through the folders and open all the "index.html" files to see the working examples as the button links dont open the pages directly (just the directories).
An example of a div which triggers a sound might be:
Code:
<div id="strum-trigger" style="cursor:pointer; cursor:hand"
onclick="soundManager.createSound({
id:'strum', url:'inc/media/strum.mp3', stream:true, autoLoad:true, autoPlay:true, multiShot:false
});
soundManager.play('strum')">
</div>
To give the user an option to turn off the sounds, I'd create a button which calls SoundManager2's "stopAll()" function ( onclick="soundmanager.stopAll();" ) but then also encorporate a bit of jQuery so the same button also hides all the divs/buttons/elements that trigger the sounds in the first place.
You can then have a 2nd button to turn sound back on again which would just be jQuery revealing all the divs/buttons/elements again that trigger the sounds.
Hope that helps
ps - A note on the sounds/music you use. Encode your audio to a max of 44.1KHz with 128kbps bitrate only otherwise otherwise it goes all chipmunk-y.
Bookmarks