Add configurable audio session mode#180
Open
marioortizmanero wants to merge 1 commit intokdroidFilter:masterfrom
Open
Add configurable audio session mode#180marioortizmanero wants to merge 1 commit intokdroidFilter:masterfrom
marioortizmanero wants to merge 1 commit intokdroidFilter:masterfrom
Conversation
Allow users to control audio interruption behavior (DoNotMix, MixWithOthers, DuckOthers) and iOS silent switch handling via a new AudioMode parameter on rememberVideoPlayerState().
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.
Summary
Currently the iOS video player hardcodes
AVAudioSessionCategoryPlaybackand the Android player doesn't set explicitAudioAttributes, so there's no way to control how the player interacts with other apps' audio. This adds a newAudioModeparameter torememberVideoPlayerState()that lets users configure interruption behavior and iOS silent switch handling.Inspired by Expo's
setAudioModeAsyncAPI, the API is a data class with composable properties rather than predefined profiles:The default
AudioMode()preserves the current behavior (exclusive playback, ignores silent switch), so this is fully backward compatible.On iOS,
InterruptionModemaps to AVAudioSession category options andplaysInSilentModecontrols the category (.playbackvs.ambient/.soloAmbient). On Android, it maps to ExoPlayer'sAudioAttributesand audio focus management. JVM desktop and web accept the parameter but ignore it.Test plan
AudioMode()(default) behaves the same as before on iOS and AndroidAudioMode(interruptionMode = MixWithOthers)lets other apps' audio continue on both platformsAudioMode(playsInSilentMode = false)respects the iOS silent switchAudioMode(interruptionMode = DuckOthers)lowers other apps' volume on both platforms