Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 761
Jimbly2 Avatar asked Jan 27 '12 21:01

Jimbly2


1 Answers

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.

like image 152
Jasper Avatar answered Sep 24 '22 23:09

Jasper