@notnotsamuel/capacitor-plugin-audiotoggle
v0.0.2
Published
A Capacitor plugin to toggle audio output between the speaker and earpiece, enabling audio playback even when the iOS silent switch is active.
Readme
capacitor-plugin-audiotoggle
A Capacitor plugin to override the iOS silent switch and control audio routing between speaker, earpiece, or normal ambient playback.
Install
npm install @notnotsamuel/capacitor-plugin-audiotoggle
npx cap syncUsage
import { AudioToggle } from '@notnotsamuel/capacitor-plugin-audiotoggle';
await AudioToggle.setAudioMode({ mode: 'speaker' });Available modes:
speaker: Force playback through speaker and ignore the iOS silent switch.earpiece: Phone-call style routing (earpiece) on Android and iOS.normal: Ambient mode that respects the silent switch.
API
setAudioMode(...)
setAudioMode(options: { mode: 'speaker' | 'earpiece' | 'normal'; }) => Promise<void>Sets the audio mode. 'speaker' = Playback (ignores silent switch on iOS, forces speaker on Android). 'earpiece' = PlayAndRecord (standard phone call behavior). 'normal' = Ambient (respects silent switch).
| Param | Type |
| ------------- | ----------------------------------------------------------- |
| options | { mode: 'speaker' | 'earpiece' | 'normal'; } |
