Skip to content

Commit

Permalink
Enable audio focus for music playback
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsvanvelzen committed Dec 28, 2024
1 parent f26a1e4 commit 0533d54
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions playback/media3/exoplayer/src/main/kotlin/ExoPlayerBackend.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.content.Context
import android.view.ViewGroup
import androidx.annotation.OptIn
import androidx.core.content.getSystemService
import androidx.media3.common.AudioAttributes
import androidx.media3.common.C
import androidx.media3.common.MediaItem
import androidx.media3.common.PlaybackException
Expand Down Expand Up @@ -101,6 +102,9 @@ class ExoPlayerBackend(
setConstantBitrateSeekingAlwaysEnabled(true)
}
))
.setAudioAttributes(AudioAttributes.Builder().apply {
setUsage(C.USAGE_MEDIA)
}.build(), true)
.setPauseAtEndOfMediaItems(true)
.build()
.also { player ->
Expand Down

0 comments on commit 0533d54

Please sign in to comment.