unmute-ios-audio
TypeScript icon, indicating that this package has built-in type declarations

3.3.0 • Public • Published

unmute-ios-audio travis npm downloads javascript style guide

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 click or 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.

Built for and used on BitMidi, a free MIDI database. Works in the browser with browserify!

install

npm install unmute-ios-audio

usage

const unmuteAudio = require('unmute-ios-audio')
 
// Call once, as early as possible in the page lifecycle
unmuteAudio()

API

unmuteAudio()

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.

thanks

The techniques used within this package were inspired by:

license

MIT. Copyright (c) Feross Aboukhadijeh.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 3.3.0
    337
    • latest

Version History

Package Sidebar

Install

npm i unmute-ios-audio

Weekly Downloads

345

Version

3.3.0

License

MIT

Unpacked Size

7.77 kB

Total Files

5

Last publish

Collaborators

  • feross