Skip to content

Add configurable audio session mode#180

Merged
kdroidFilter merged 1 commit intokdroidFilter:masterfrom
marioortizmanero:feat/configurable-audio-session
Apr 10, 2026
Merged

Add configurable audio session mode#180
kdroidFilter merged 1 commit intokdroidFilter:masterfrom
marioortizmanero:feat/configurable-audio-session

Conversation

@marioortizmanero
Copy link
Copy Markdown
Contributor

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().
@kdroidFilter kdroidFilter merged commit e8ff884 into kdroidFilter:master Apr 10, 2026
@kdroidFilter
Copy link
Copy Markdown
Owner

Thank you so much, fantastic!

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.

2 participants