HTML5 Mobile needs a tap to start playing

I’m trying to play an audio file on iOS (chrome and safari so far) and it seems that it requieres a tap for start playing.
I understand that now the library for sounds is howler.js, is this related with the issue? Is there a workaround for this?

Could you try editing your index.html, and adding this before lime.embed?

Howler.mobileAutoEnable = true;



I believe there does need to be a tap at some point to enable playback, but if this triggers soon enough, then the tap will occur early enough that it might not be intrusive.

Or is the issue that the audio should play before any taps at all have occurred? Did this work before with SoundJS?

Howler appears to use “touchend” when it tries to unlock audio, this is something I found from SoundJS:

In SoundJS 0.6.2 and above, SoundJS will automatically listen for the first document-level “mousedown” and “touchend” event, and unlock WebAudio. This will continue to check these events until the WebAudio context becomes “unlocked” (changes from “suspended” to “running”)

Thanks @singmajesty
I tried but no luck.
It needs a tap the first time it plays audio, then everything goes fine.
I don’t remember if this worked or not with SoundJS.

Anyone? Any other ideas?

It appears to be a limitation of iOS web audio

I had a similar issue with sounds not playing unless initiated by a tap. As my game had a “click play to start” button I also triggered the playback of a silent wav at this time. After that all in game sound effects played as expected.

I do appreciate that this will only work for you if you have a tap at some point…

It’s a ‘feature’ of iOS Safari (and other iOS browsers I think). The user does have to tap in order to play sound. A splash screen with a play button is the most obvious choice, but if you want to play music on your home screen you may have a button or note to tap to play music. There are many iOS web apps that do this, but you can certainly load some games up on iOS Safari and see how they handle the design.