Android Chrome does not allow applications to play HTML5 audio without an explicit action by the user
I was working a site that required to play some sound effects at different times and when testing on my Android phone, I was very surprised to find that only some of the sounds would play.
I assumed that there must be a restriction on bit rate or something else specific to the sound file as some played fine and others didn’t play at all, all using the same code.
I then stumbled across this chromium issue 178297 https://code.google.com/p/chromium/issues/detail?id=178297
It turns out there is a mobile specific restriction put in place to disable playback of media if not a direct result of user interaction.
Now I can see why this exists as I HATE auto play videos and ads and they would be even worse on mobile, however I have a valid use for this.
The reason only some of my sounds worked was some were triggered by a button click, while other were trigged by a URL hash change.
A button click is a user interaction / gesture but hash change is not.
Luckily Philip Jägenstedt has found a work around to the situation by using the first user interaction to “warm up” or initialise each audio element.
This then allows non user interaction events to use the elements moving forward.
His post on the issue, including his workaround is at http://blog.foolip.org/2014/02/10/media-playback-restrictions-in-blink/
I would assume everyone has as some stage come across the scourge that is w3schools. <- see not linked. Also please don't Google them…
This has been a problem for some time and even blocking them from your search results is not easy.
Fortunately someone has done something about this.
Unfortunately it is not high in the search rankings however thus non informed / beginners are not seeing the gold mine of information.
This is something I thought I don't have much control over and just needed to do my best to tell people not to use w3schools.
Last night I attended and spoke at the first BrisJS Meetup for 2012
This is great! I get a simple, easy way to promote a far superior reference site and also assist in the SEO for MDN to hopefully one day knock w3schools off the top.
It might not be time to spam F5 at arewefirstyet.com yet but the day will come!
So I implore you. Every chance you get. Add a promotejs.com link on your site, page, blog or anywhere you can get away with it…
Last night I spoke at the first BrisJS Meetup for 2012
For those interested the slides for the presentation can be found here.
(Please feel free to send me a pull request to fix my atrocious spelling…)
As this is an impress.js presentation a decent browser is required to view the correctly but the fall back should work if you are still forced to use a trojan…