Page MenuHomePhabricator

Audio on iOS is muted if phone ringer is set to silent
Closed, ResolvedPublicBUG REPORT

Description

Audio on iOS seems busted if the first element you open does not support native playback.

Take https://m.mediawiki.org/wiki/User:Brion_VIBBER/Vidtest_LTR
The first videos do not allow audio playback using ogvjs. But after you open the bottom audio clips (which have native mp3 tracks available), the audio works, and then the audio playback in the videos work as well on my iOS device.

This indicates a problem with initiating the autoplay permission for the audiocontext perhaps ????

Event Timeline

TheDJ triaged this task as High priority.Feb 14 2022, 11:11 PM
TheDJ changed the subtype of this task from "Task" to "Bug Report".

@brion Right, i forgot.. WebAudio, specifically AudioBufferSourceNode, on iOS isn't on the media channel, but on the default audio/ringer channel and therefor doesnt work if you have your mute toggle on the iPhone set... I remember finding this out before, but what the heck Apple...

Apparently there is a little trick around that by playing silence on an <audio> element, which will open the media channel and then mix the webapi sound in, but ... kinda dodgy
https://github.com/swevans/unmute/blob/master/unmute.js#L171

TheDJ renamed this task from Autoplay on iOS no longer allows audio playback to Audio on iOS is muted if phone ringer is set to silent.Mar 3 2022, 8:37 PM
TheDJ lowered the priority of this task from High to Medium.

Change 777897 had a related patch set uploaded (by Brion VIBBER; author: Brion VIBBER):

[mediawiki/extensions/TimedMediaHandler@master] Workaround for audio with ringer off on iOS

https://gerrit.wikimedia.org/r/777897

Workaround seems to be doing the job; before creating the AudioContext, I have it create an <audio> with a short silent MP3 and force it to play. This seems to get the system audio mixer to see it as media instead of ringer, and the hardware ringer switch no longer disables the Web Audio output.

I've included this both into ogv.js when using the default code path, and locally in TMH because we locally create an AudioContext ahead of time to allow for lazy loading without worrying about whether the user gesture got forwarded via events.

If it's too much to review the ogv.js 1.8.9 updates (which are not huge upstream, but the compiled minified output is all gibberish) we can cherry-pick the local patch and it should still work correctly on ogv.js 1.8.6.

Change 777897 merged by jenkins-bot:

[mediawiki/extensions/TimedMediaHandler@master] Workaround for audio with ringer off on iOS

https://gerrit.wikimedia.org/r/777897

TheDJ assigned this task to brion.