Enable/unmute WebAudio on iOS, even while mute switch is on
On Safari for iOS, audio is allowed to play when the device's mute switch is enabled, but only for HTML5 audio tags, and not for Web Audio. This module fixes that and adds consistency and reliability to web audio in Safari. Note that a "user activation" in the form of a
touchstart event is still required to play audio. This package merely unmutes Web Audio even while the mute switch is enabled on the device.
This package works by playing a short, silent sound using an
<audio> tag and an
AudioContext whenever the user interacts with the page. That's it.
npm install unmute-ios-audio
const unmuteAudio =// Call once, as early as possible in the page lifecycle
Enable/unmute the WebAudio API on iOS, even while the mute switch is on.
Call this function as early as possible so that the user event handlers can be registered and you don't miss any user interactions which could have been used to unmnute the audio.
The techniques used within this package were inspired by:
MIT. Copyright (c) Feross Aboukhadijeh.