Skip to content

Enables web applications to play audio even when an iPhone or iPad’s physical mute switch is engaged

License

Notifications You must be signed in to change notification settings

activetheory/ios-silent-bypass

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

iOS Silent Bypass

iOS Silent Bypass is a library that allows you to play audio context even if the user has the action button/silent switch on. You'll need to wait for an user interaction to check if the audio context is allowed.

Usage

npm install @activetheory/ios-silent-bypass
import SilentBypass from '@activetheory/ios-silent-bypass';

function isIOS() {
  return navigator.userAgent.includes('iPhone') || navigator.userAgent.includes('iPad');
}

let silentBypass;

if (isIOS()) {
  silentBypass = new SilentBypass();
}

// after the library is initialized, you can check if the audio context is allowed
console.log(silentBypass?.allowed);

// if you want to remove the event listeners after the audio context is allowed, you can call the destroy method
silentBypass?.destroy();

License

MIT

About

Enables web applications to play audio even when an iPhone or iPad’s physical mute switch is engaged

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published