iOS ringer switch mutes web audio
Asked Answered
M

2

5

In a project I'm working on I noticed that, on iOS, the sounds are muted when the ringer switch is turned off. The project is based on CreateJS and the sounds are managed by SoundJS.

Frustratingly, other websites that use sounds/media (youtube, facebook, soundhound, spotify, etc) seem unaffected by the ringer switch.

I tested on a few different iPhones with iOS versions ranging from 9.2 to 10.1.1: all presented the same issue.

What could be reason of this behaviour? Is there any documentation around that might explain how to fix it?

Mcnair answered 24/11, 2016 at 14:39 Comment(0)
G
7

Old thread, but I have hit this before and answered a question on SO previously.

Basically, iOS will play web audio on the ringer category. I plays HTML audio on the media category (as expected). You can force BOTH to play on the media category by playing a silent looping html sound in the background. This does have one side effect- you'll now be given the option to airplay the game audio and toggle play/pause on the notifications view & lock screen if the screen is switched off while safari is open. The solution linked to below isn't a super robust solution (ie that side effect), but it definitely obtains the behavior you're looking for. Hope this helps!

See my answer here- https://mcmap.net/q/1021680/-ios-webaudio-only-works-on-headphones

Gereron answered 22/2, 2019 at 19:34 Comment(0)
C
0

I'm not sure if this is why your sounds won't play with the ringer switch on, but there is a limitation to autoplaying sounds in Mobile Safari - they must be triggered by touch events (http://www.ibm.com/developerworks/library/wa-ioshtml5/)

I assume you are making a webapp and not using something like Phonegap or a browser view inside an app. If the latter, you might try looking into AVAudioSession categories which dictate things like your app's audio mixing with others and being silenced/not silenced by the ringer switch.

Clair answered 25/11, 2016 at 11:34 Comment(2)
The touch-initialisation works fine, the sound DOES work when the ringer switch is on. But i'm expecting it to work also when the ringer is off, since that's the behaviour observe on other websites.Mcnair
And yes, it's a webapp, nothing to do with phonegap or webviews. I'm actually testing in Safari to avoid Chrome's webview issues for now.Mcnair

© 2022 - 2024 — McMap. All rights reserved.