I have created a sample phone gap application for android ics . And the index.html has an audio tag like this.
<audio id="player1" controls preload><source src="media/track1.mp3" type="audio/mp3" /></audio>
I am not able to play the audio at all. I saw the stack overflow posts everywhere it’s mentioned that the audio tag will work fine after froyo release. But, i am testing it in gingerbeard and in ICS and it’s not working anywwhere.
HTML5 Audio support is not consistent across different devices/OSes due to codec licensing issues and OS implementation/support. If you are just playing MP3 files, you can reliably handle those by using PhoneGap’s Media class, which will provide consistent and reliable audio programming on all platforms.
If you want the ability to preload audio and have more advanced scenarios like polyphony or layering (like video game effects), you can use the LowLatencyAudio PhoneGap native plugin.
Super late to this but
type="audio/mp3" is wrong – it should be
With that being said, Android is still terrible at playing HTML5 audio – you’re required to reset the
src attribute before playing sounds (or they’ll only play once) and it’s not tolerant of multiple file types (required for other browsers). Nor do they support the WebAudioAPI
According to html5test.com Android 4 only supports mp3 in the audio tag.
Wish I answered with some findings earlier.
The following seem to work for me. Android seems very anal about which source comes first. So I had the “mp3” source as on the third line and moved it up so it works for sure now. The controls=controls is because without it IE 11 did not seem to work on regular PC. My thoughts on the matter. Had to make the copy in ogg for Firefox to recognize it.
<audio controls="controls"> <source src="/somefile.mp3" type="audio/mpeg"></source> <source src="/somefile.ogg" type="audio/ogg"> Your browser does not support the audio element. </source></audio>
It looks like the path to your mp3 is incorrect. If this file is on the SD card the path would be something like: