Skip to content

Pass the right channel volume to setVolume on iOS - #897

Open
c960657 wants to merge 1 commit into
zmxv:masterfrom
c960657:fix-setvolume-argument-count
Open

Pass the right channel volume to setVolume on iOS#897
c960657 wants to merge 1 commit into
zmxv:masterfrom
c960657:fix-setvolume-argument-count

Conversation

@c960657

@c960657 c960657 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Calling setVolume() on a Sound raises a warning on iOS:

RNSound.setVolume was called with 2 arguments but expects 3 arguments. If you haven't changed this method yourself, this usually means that your versions of the native code and JavaScript code are out of sync. Updating both should make this error go away.

The native method takes a volume per channel. RNSound.mm declares

RCT_EXPORT_METHOD(setVolume:(double)key left:(double)left right:(double)right)

and both TurboModule specs agree:

setVolume: (key: number, left: number, right: number) => void;

but the iOS branch of setVolume() passed only the key and a single volume. Pass the value for both channels, which is what setAndroidVolumes() already does when there is no pan.

TypeScript does not catch this because SoundModule is produced by an untyped require(), so RNSound is any and none of the call sites are checked against the Spec interfaces.

Calling setVolume() on a Sound threw on iOS:

    RNSound.setVolume was called with 2 arguments but expects 3 arguments.

The native method takes a volume per channel. RNSound.mm declares

    RCT_EXPORT_METHOD(setVolume:(double)key left:(double)left right:(double)right)

and both TurboModule specs agree:

    setVolume: (key: number, left: number, right: number) => void;

but the iOS branch of setVolume() passed only the key and a single volume,
so the call failed. Pass the value for both channels, which is what
setAndroidVolumes() already does when there is no pan.

TypeScript does not catch this because SoundModule is produced by an
untyped require(), so RNSound is any and none of the call sites are
checked against the Spec interfaces.
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