Skip to content

Instantly share code, notes, and snippets.

@gbishop
Created December 21, 2011 20:04
Show Gist options
  • Save gbishop/1507481 to your computer and use it in GitHub Desktop.
Save gbishop/1507481 to your computer and use it in GitHub Desktop.
Play sound on the iPad from Javascript using jquery mobile
I keep forgetting how to do this...
To play audio in Safari on the iPad using javascript you have to create the audio node in response to a user event. You have to give the audio node a legal url and call load. Then reuse that same node to play sounds in the future.
In jquery mobile I bound to the 'tap' event on body. If I haven't already created the audio object I create it there. Then I can use it later.
@swlasse
Copy link

swlasse commented Jun 28, 2012

Brilliant, thanks - works perfect :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment