Skip to content

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

Merged
mdydek merged 3 commits into
software-mansion:mainfrom
lpmv:feat/audiomanager-get-system-volume
Aug 19, 2026
Merged

feat: AudioManager.getSystemVolume() — synchronous system volume read#1211
mdydek merged 3 commits into
software-mansion:mainfrom
lpmv:feat/audiomanager-get-system-volume

Conversation

@lpmv

@lpmv lpmv commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

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.
@closetcaiman closetcaiman added the feature New user-facing features or major capabilities label Aug 5, 2026
@mdydek

mdydek commented Aug 11, 2026

Copy link
Copy Markdown
Member

@closetcaiman closetcaiman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the documentation.

Comment thread packages/react-native-audio-api/src/system/types.ts Outdated
@github-actions

Copy link
Copy Markdown

WPT non-regression comparison

PASS — no regressions · 3 improved section(s) · overall 2574 → 2585 (+11)

Spec section Base pass Head pass Delta
AnalyserNode 137 138 +1
AudioParam 597 599 +2
WaveShaperNode 67 75 +8
Unchanged sections (25)
Spec section Base pass Head pass Delta
Processing model 0 0 0
Other 52 52 0
AudioBuffer 140 140 0
AudioBufferSourceNode 208 208 0
AudioContext 54 54 0
AudioNode 261 261 0
BiquadFilterNode 232 232 0
ChannelMergerNode 30 30 0
ChannelSplitterNode 7 7 0
ConstantSourceNode 59 59 0
ConvolverNode 170 170 0
DelayNode 104 104 0
DestinationNode 0 0 0
DynamicsCompressorNode 4 4 0
GainNode 15 15 0
IIRFilterNode 87 87 0
MediaElementAudioSourceNode 0 0 0
MediaStreamAudioDestinationNode 1 1 0
MediaStreamAudioSourceNode 0 0 0
OfflineAudioContext 35 35 0
OscillatorNode 104 104 0
PannerNode 75 75 0
PeriodicWave 33 33 0
ScriptProcessorNode 0 0 0
StereoPannerNode 102 102 0

Baseline: b0c368490c35169977de71991b0e882672684c2f · Candidate: d2e533b99cdb308bd0f6051ae493f74c5ef1e3d2

Workflow run · this comment is updated on every push.

@mdydek
mdydek merged commit 9b28ad4 into software-mansion:main Aug 19, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New user-facing features or major capabilities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants