Search code examples
htmljquery-mobile

Playing audio with jQuery Mobile


Using HTML5 and jQuery Mobile I have a page with 3 buttons.

What I want to do is have each button select a different sound, then have another button to play the selected sound.

Can anyone give me a steer?

Thanks

Jim


Solution

  • Check-out the HTML5 <audio> tag. You can pre-load audio clips and play them when the user interacts with elements.

    Docs for <audio>: https://developer.mozilla.org/en/HTML/Element/audio

    You may want to check-out a pre-made plugin for this, I have seen JPlayer used a lot: http://jplayer.org/

    Although a plugin will not be necessary, the HTML5 <audio> tag comes with the ability to control it using JavaScript.