Skip to content

Add configurable audio session mode#180

Open
marioortizmanero wants to merge 1 commit intokdroidFilter:masterfrom
marioortizmanero:feat/configurable-audio-session
Open

Add configurable audio session mode#180
marioortizmanero wants to merge 1 commit intokdroidFilter:masterfrom
marioortizmanero:feat/configurable-audio-session

Conversation

@marioortizmanero
Copy link

Summary

Currently the iOS video player hardcodes AVAudioSessionCategoryPlayback and the Android player doesn't set explicit AudioAttributes, so there's no way to control how the player interacts with other apps' audio. This adds a new AudioMode parameter to rememberVideoPlayerState() that lets users configure interruption behavior and iOS silent switch handling.

Inspired by Expo's setAudioModeAsync API, the API is a data class with composable properties rather than predefined profiles:

// Mix with other apps' audio
rememberVideoPlayerState(
    audioMode = AudioMode(interruptionMode = InterruptionMode.MixWithOthers)
)

// Ambient: respect silent switch, mix with others
rememberVideoPlayerState(
    audioMode = AudioMode(
        interruptionMode = InterruptionMode.MixWithOthers,
        playsInSilentMode = false,
    )
)

The default AudioMode() preserves the current behavior (exclusive playback, ignores silent switch), so this is fully backward compatible.

On iOS, InterruptionMode maps to AVAudioSession category options and playsInSilentMode controls the category (.playback vs .ambient/.soloAmbient). On Android, it maps to ExoPlayer's AudioAttributes and audio focus management. JVM desktop and web accept the parameter but ignore it.

Test plan

  • Verify AudioMode() (default) behaves the same as before on iOS and Android
  • Verify AudioMode(interruptionMode = MixWithOthers) lets other apps' audio continue on both platforms
  • Verify AudioMode(playsInSilentMode = false) respects the iOS silent switch
  • Verify AudioMode(interruptionMode = DuckOthers) lowers other apps' volume on both platforms

Allow users to control audio interruption behavior (DoNotMix,
MixWithOthers, DuckOthers) and iOS silent switch handling via
a new AudioMode parameter on rememberVideoPlayerState().
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