Platform: Android version 4.x
Issue: HTML 5 Audio Tag
Compiled: Framework Phonegap
I have been trying to play a simple sound with HTML 5, i cant get it to work.
I read that there is a general "not supporting" thing going on with Android, but as i understand it, version 4.x supports HTML 5 Audio tag.
Config.xml I did enable some of the features in it eg. File access, device access and so, i even tried to include all features. Just to let u guys know.
HTML This is what i am working with atm, i figured that maybe i should go back to directly try and get a sound out, then make the costum controls with JQ.
<audio controls="true">
<source src="media/sound.mp3" type="audio/mpeg">
<source src="media/sound.ogg" type="audio/ogg">
<source src="media/sound.wav" type="audio/wav">
Your browser does not support HTML5 audio.
</audio>
Conclusion So far i havent hear any sounds, i tried to trigger it different ways like:
var Newsound = new Audio("sound.ogg");
Newsound.play();
Any idea or suggestion is welcome.
Thanks in advance :-)
You generally need a piece of JavaScript to get this working. Try the following:
<audio id="a" controls="true">...
var audio = document.getElementById('a');
audio.addEventListener('touchstart', function() { audio.play(); }, false);
When a user touches the audio element the sound should now play.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With