I've made an HTML5 iPod.
You can try it here.
http://inventikasolutions.com/demo/iPod
On a PC, while using Chrome. If I navigate to a song, it starts playing automatically. But while using Chrome on Android it doesn't play the song. I have to hit the play/pause button again to play the audio.
Here is the code which runs, when you select the song to play:
audioPlayer.src=songurl[number];
audioPlayer.oncanplaythrough = "isAppLoaded";
audioPlayer.autoplay = "autoplay";
audioPlayer.addEventListener('ended',nextSong,false);
document.getElementById("player").appendChild(audioPlayer);
and here is the play/pause code.
if (audioPlayer.paused)
{
audioPlayer.play();
$("#pauseindicator").hide();
$("#playindicator").show();
}
else
{
audioPlayer.pause();
$("#pauseindicator").show();
$("#playindicator").hide();
}
Could it have some thing to do with the 'autoplay' variable? The default browser in Android plays the song immediately.
Thanks.
Just add an invisible iframe with an . mp3 as its source and allow="autoplay" before the audio element. As a result, the browser is tricked into starting any subsequent audio file. Or autoplay a video that isn't muted.
Chrome no longer allows audio autoplay and video autoplay with sound. I expect other browsers to follow suit in the near future. I totally understand that video ads with sound that start playing out of nowhere are super annoying. They are the reason for this policy change.
In case someone bumps into this - Android version of Chrome in fact blocks autoplay function, but you can change settings of the browser. To do this, you have to enter chrome://flags and set Disable gesture requirement for media playback to on. It's impossible to force this setting via web, but if you're writing a dedicated web app like I did, you can use it.
Please refer this link ...
http://code.google.com/p/chromium/issues/detail?id=138132
Chrome does not allow applications to play HTML5 audio without an explicit action by the user, similar to how it is handled by iOS, but differently than the stock Android browser handles it.
Autoplay is not honored on android as it will cost data usage.
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