@kontextso/soundon
v1.0.0
Published
SoundOn module for React Native
Keywords
Readme
@kontextso/soundon
Tiny React Native module to detect if the device media volume is ON (greater than 0).
Works on iOS and Android. No permissions required.
Installation
# with npm
npm install @kontextso/soundon
# with yarn
yarn add @kontextso/soundonAfter installing, run platform-specific native installs:
- iOS: from your app's
ios/directory
pod install- Android: autolinking will register the module automatically (React Native >= 0.60).
Expo
This package contains native code. In Expo you need to use a Custom Dev Client or the Bare workflow.
- For development: run
expo prebuildand useexpo run:ios/expo run:android, or build a custom dev client with EAS. - Managed workflow without a custom client is not supported.
Usage
import {isSoundOn} from '@kontextso/soundon';
async function checkVolume() {
try {
const on = await isSoundOn();
console.log('Media volume is', on ? 'ON (> 0)' : 'OFF (0)');
} catch (e) {
// iOS may reject if the audio session cannot be activated
console.warn('Failed to read output volume', e);
}
}API
isSoundOn(): Promise<boolean>- Resolves
trueif the current media/output volume is greater than 0, otherwisefalse. - On iOS, the promise can reject (error code:
soundon_error) if the audio session cannot be activated.
- Resolves
Platform details
iOS
- Uses
AVAudioSession.sharedInstance()and readsoutputVolume. - Temporarily sets the session category to
.ambientwith.mixWithOthersand activates the session to read volume. - Does not start playback and should not interrupt other audio.
- Uses
Android
- Uses
AudioManagerand comparesSTREAM_MUSICcurrent volume to its max.
- Uses
Notes and limitations
- This checks media/output volume only.
- It does NOT account for:
- iPhone ring/silent switch
- Do Not Disturb / Focus modes
- Per‑app volume or hardware controls on external devices
- The value is point-in-time. Call
isSoundOn()again to refresh. The module does not emit change events.
