Skip to content

feat: AudioManager.getSystemVolume() — synchronous system volume read - #1211

Open
lpmv wants to merge 1 commit into
software-mansion:mainfrom
lpmv:feat/audiomanager-get-system-volume
Open

feat: AudioManager.getSystemVolume() — synchronous system volume read#1211
lpmv wants to merge 1 commit into
software-mansion:mainfrom
lpmv:feat/audiomanager-get-system-volume

Conversation

@lpmv

@lpmv lpmv commented Aug 2, 2026

Copy link
Copy Markdown

Why

AudioManager can observe volume changes (observeVolumeChanges + the volumeChange event) but has no way to read the volume before any change has fired. An app that wants to warn "your volume is at the floor" at the moment the user presses play cannot know the current level until the user happens to press a volume button.

What

A synchronous read on the exact scale the volumeChange event already reports:

const volume = AudioManager.getSystemVolume(); // 0..1
  • iOS: AVAudioSession.outputVolume
  • Android: STREAM_MUSIC volume as a fraction of its maximum

Exposed via the TurboModule spec mirroring getDevicePreferredSampleRate's blocking-synchronous form; the iOS implementation delegates to AudioSessionManager like its siblings.

Notes

The JSDoc carries the honest iOS caveat: a cold read before any volume-change event can report a stale or zero value on some iOS versions (KVO on outputVolume is the trustworthy stream once it speaks); callers who care can treat an exact 0.0 cold read as suspect. That caveat exists with or without this API — this just gives apps the same read the KVO baseline uses.

AudioManager can observe volume changes (observeVolumeChanges + the
volumeChange event) but has no way to read the volume BEFORE any change has
fired - e.g. an app that wants to warn 'your volume is at the floor' at the
moment the user presses play cannot know the current level until the user
happens to press a volume button.

This adds the synchronous read on the exact scale the volumeChange event
already reports:

  - iOS: AVAudioSession.outputVolume
  - Android: STREAM_MUSIC volume / STREAM_MUSIC max volume (0..1)

exposed as AudioManager.getSystemVolume(): number via the TurboModule spec,
mirroring getDevicePreferredSampleRate's blocking-synchronous form.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant