Skip to content

Commit

Permalink
handle audio focus and noisy
Browse files Browse the repository at this point in the history
Signed-off-by: parneet-guraya <gurayaparneet@gmail.com>
  • Loading branch information
parneet-guraya authored and JuancaG05 committed Dec 18, 2023
1 parent 40dcf0f commit 03d4cde
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import androidx.core.view.WindowInsetsControllerCompat
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import androidx.media3.common.AudioAttributes
import androidx.media3.common.PlaybackException
import androidx.media3.common.Player
import androidx.media3.common.util.UnstableApi
Expand Down Expand Up @@ -189,7 +190,10 @@ class PreviewVideoActivity : FileActivity(), Player.Listener, OnPrepareVideoPlay
private fun initializePlayer() {
val videoTrackSelectionFactory = AdaptiveTrackSelection.Factory()
trackSelector = DefaultTrackSelector(this, videoTrackSelectionFactory)
player = ExoPlayer.Builder(this).setTrackSelector(trackSelector)
player = ExoPlayer.Builder(this)
.setAudioAttributes(AudioAttributes.DEFAULT, true)
.setHandleAudioBecomingNoisy(true)
.setTrackSelector(trackSelector)
.setLoadControl(DefaultLoadControl.Builder().build()).build()

player?.addListener(this)
Expand Down

0 comments on commit 03d4cde

Please sign in to comment.