I'm using a .mp3 file, the .mp3 file plays okay when viewed directly and also when embeded using the HTML5 audio tag, however when creating the HTML5 audio tag in JS it does not play! (very strange)
I do not have this issue in any other browser/device, for example Desktop - Chrome works perfectly.
sound = document.createElement('audio');
sound.setAttribute('src', 'sound.mp3');
sound.play();
I've tested sound.canPlayType('audio/mpeg') and this produces true (so it is supported).
Perhaps there's a bug in Android - Chrome? (it is the latest version)
audio
element well in advance. Listen to thecanplay
orcanplaythrough
event fired by theaudio
element to know when it has enough data to begin playback. – Touffyaudio
can't be played back programatically, then that's that (but please check my hypothesis too). You could try using the Web Audio API as an alternative. It's a bit more code but also has much more power. – Touffyaudio
element is part of the HTML. So it can't be a network thing. – Touffy