Pass the right channel volume to setVolume on iOS - #897
Open
c960657 wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Calling
setVolume()on aSoundraises a warning on iOS:The native method takes a volume per channel. RNSound.mm declares
and both TurboModule specs agree:
but the iOS branch of
setVolume()passed only the key and a single volume. Pass the value for both channels, which is whatsetAndroidVolumes()already does when there is no pan.TypeScript does not catch this because SoundModule is produced by an untyped
require(), so RNSound isanyand none of the call sites are checked against the Spec interfaces.