unmute-ios-audio icon indicating copy to clipboard operation
unmute-ios-audio copied to clipboard

Does it still work with current iOS versions?

Open dlymann opened this issue 3 years ago • 8 comments

We've been using that package for a while and it worked well. However, with current iOS versions it doesn't seem to work anymore. At least with our application.

Version 3.1.0 works with old versions of iOS like 12.5.3 (on an iPhone 6). Version 3.2 and 3.3 do not work there as well.

On newer iOS 14.5 or iPad Os etc. our app suddenly doesn't work together with this package using any version of it. Can you confirm, that it still should basically work (... and that the issue may be the setup in our project)?

Thank you very much.

dlymann avatar May 17 '21 20:05 dlymann

Hi @dleumann, the library uses the prefixed webkitAudioContext to detect Safari. Sadly (or luckily) that doesn't work anymore since Safari now removed the prefix.

I'm not sure though what should be used instead now. @feross what do you think?

I had a quick look at the expectation tests that I maintain for standardized-audio-context. The following works today but might break with the next release.

const isSafariWithModernWebAudioImplementation = () => {
    try {
        new AudioContext({ sampleRate: 0 });
    } catch (err) {
        return err.code === 12;
    }
}

console.log(isSafariWithModernWebAudioImplementation());

chrisguttandin avatar May 17 '21 20:05 chrisguttandin

Hello and thanks for the update. For the time being I trigger a very short silence file when the user touches the screen. This seems to activate the sound even if the sound is muted on the device.

e.g. new Audio('workarounds/silence.mp3').play()

dlymann avatar May 18 '21 09:05 dlymann

Just chiming in to say that iOS 14.5 changed quite a few arcane Audio API tidbits, and this one also bit me. Since the detection method won't be quite as easy going forward, it'd be really nice to at least have an argument to the default export function to force it to continue (even if detection fails), since a lot of apps will be doing their own iOS-specific detection

searls avatar May 31 '21 18:05 searls

For example, here's the patch I just did to workaround my own need: https://github.com/searls/unmute-ios-audio/commit/8fc05cdb0d0f63167e0d6047ed1932555b3c9491

searls avatar May 31 '21 19:05 searls

so, how to make this work on iOS 14.5+ ?

martijnmichel avatar Jul 02 '21 06:07 martijnmichel

+1 looking for a workaround. Tried @searls approach, but doesn't seem to work on my end.

freshlySqueezedBananas avatar Aug 02 '21 14:08 freshlySqueezedBananas

https://github.com/swevans/unmute

This works on IOS 14.5 +

Seanitzel avatar Sep 01 '21 16:09 Seanitzel

https://github.com/swevans/unmute

This works on IOS 14.5 +

I use this one too it's awesome

You can find alternative version where the audio stays playing when switching tabs or view https://spencer-evans.com/share/github/unmute-no-pause/

It even works in a webview cordova and capacitor, with background mode as well so that webaudio can play in the background.

numerized avatar Nov 06 '21 01:11 numerized