View
 

Sounds

Page history last edited by Devon Weller 1 year, 11 months ago

I like Phonegap a lot! Just wondering, how can I insert an audioplayer with Phonegap in my iPhone app? Or any audio at all?

 

HowTo

  • Place your beep.wav in the Resources folder
  • Execute new Media('beep.wav').play();
    • See notification source in demo code

 

Supported Devices

  • iphone
    • Formats: .wav, .aiff
    • Note that while .mp3 works in the Simulator, it does not work on the actual device (On the EDGE version >= 0.8.2, .mp3 works on the device).

?

 

In the edge version of phonegap, the sound file must be included in the www folder.  For the above example, beep.wav would need to be in the www folder.  Older versions of PhoneGap may have required the file to be in the Resources group of your xcode project.

 

You may also reference audio files in a subfolder.  Executing new Media('audio/mysound.wav').play(); will play a wave file in www/audio/mysound.wav.

 

To loop a sound, pass the option "numberOfLoops" like this:

 

new Media('audio/mySong.wav').play({numberOfLoops:99});

 

 

References

 

Feature Requests / Plans