Play an MP3 File in PhoneGap

There is nothing special about playing a plain MP3 file in Phonegap. You can typically just use HTML5 audio. Here's an example.

<audio controls>
  <source src="sound.ogg" type="audio/ogg">
  <source src="sound.mp3" type="audio/mpeg">
Your browser doesn't support audio.
</audio>

That should be all you need. Nothing special here.

I included both ogg and mp3 files because some browsers support mp3 and some don't (we use ogg for those). iOS and Android both support mp3, so you might only need the mp3 version for mobile development. Firefox doesn't support mp3 and the upcoming Firefox and Ubuntu phones might need the ogg file. Those don't have much market share at present, so ogg might not be necessary at all.

For $9.95 Get Answers to Your PhoneGap Questions

Send me an email and explain the problem. I'll send back my step by step instructions.

Subscribe

Only $9.95

After, I'll be on retainer to answer your other questions. If you don't need any more help, cancel anytime.

Please hurry, only 2 slots are available.

You may also be interested in how to Play an MP3 Audio Stream in PhoneGap.

comments powered by Disqus
play_an_mp3_file_in_phonegap.1438612967.txt.gz · Last modified: 2020/06/01 22:53 (external edit)