@@ -135,8 +135,7 @@ class ExoPlayerCore(private val activity: Activity) : Player.Listener {
|
||||
exoPlayer?.pause()
|
||||
}
|
||||
}
|
||||
AudioManager.AUDIOFOCUS_LOSS_TRANSIENT,
|
||||
AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK -> {
|
||||
AudioManager.AUDIOFOCUS_LOSS_TRANSIENT -> {
|
||||
Log.d(TAG, "Audio focus lost transiently")
|
||||
hasAudioFocus = false
|
||||
if (isInitialized) {
|
||||
@@ -144,6 +143,10 @@ class ExoPlayerCore(private val activity: Activity) : Player.Listener {
|
||||
exoPlayer?.pause()
|
||||
}
|
||||
}
|
||||
AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK -> {
|
||||
Log.d(TAG, "Audio focus lost transiently (can duck), continuing playback")
|
||||
// Don't pause — let the system handle volume ducking for notifications
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1105,7 +1108,6 @@ class ExoPlayerCore(private val activity: Activity) : Player.Listener {
|
||||
.build()
|
||||
)
|
||||
.setOnAudioFocusChangeListener(audioFocusChangeListener, handler)
|
||||
.setWillPauseWhenDucked(true)
|
||||
.build()
|
||||
|
||||
audioFocusRequest = focusRequest
|
||||
|
||||
@@ -119,21 +119,8 @@ class MpvPlayerCore(private val activity: Activity) :
|
||||
}
|
||||
}
|
||||
AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK -> {
|
||||
Log.d(TAG, "Audio focus lost transiently (can duck)")
|
||||
// For video content, we pause instead of ducking
|
||||
// since dialogue is typically important
|
||||
hasAudioFocus = false
|
||||
if (isInitialized) {
|
||||
try {
|
||||
val isPaused = MPVLib.getPropertyBoolean("pause")
|
||||
wasPlayingBeforeFocusLoss = !isPaused
|
||||
if (!isPaused) {
|
||||
MPVLib.setPropertyBoolean("pause", true)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "Failed to pause on duck focus loss", e)
|
||||
}
|
||||
}
|
||||
Log.d(TAG, "Audio focus lost transiently (can duck), continuing playback")
|
||||
// Don't pause — let the system handle volume ducking for notifications
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -361,7 +348,6 @@ class MpvPlayerCore(private val activity: Activity) :
|
||||
.build()
|
||||
)
|
||||
.setOnAudioFocusChangeListener(audioFocusChangeListener, handler)
|
||||
.setWillPauseWhenDucked(true)
|
||||
.build()
|
||||
|
||||
audioFocusRequest = focusRequest
|
||||
|
||||
Reference in New Issue
Block a user