pull/1421/head
gedoor 3 years ago
parent 61f90728a1
commit 4de11cb0ce
  1. 6
      app/src/main/java/io/legado/app/service/BaseReadAloudService.kt

@ -275,14 +275,14 @@ abstract class BaseReadAloudService : BaseService(),
override fun onAudioFocusChange(focusChange: Int) { override fun onAudioFocusChange(focusChange: Int) {
when (focusChange) { when (focusChange) {
AudioManager.AUDIOFOCUS_GAIN -> { AudioManager.AUDIOFOCUS_GAIN -> {
// 重新获得焦点, 可做恢复播放,恢复后台音量的操作 AppLog.put("重新获得焦点, 恢复播放")
if (!pause) resumeReadAloud() if (!pause) resumeReadAloud()
} }
AudioManager.AUDIOFOCUS_LOSS -> { AudioManager.AUDIOFOCUS_LOSS -> {
// 永久丢失焦点除非重新主动获取,这种情况是被其他播放器抢去了焦点, 为避免与其他播放器混音,可将音乐暂停 AppLog.put("永久丢失焦点")
} }
AudioManager.AUDIOFOCUS_LOSS_TRANSIENT -> { AudioManager.AUDIOFOCUS_LOSS_TRANSIENT -> {
// 暂时丢失焦点,这种情况是被其他应用申请了短暂的焦点,可压低后台音量 AppLog.put("暂时丢失焦点, 暂停播放")
if (!pause) pauseReadAloud(false) if (!pause) pauseReadAloud(false)
} }
AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK -> { AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK -> {

Loading…
Cancel
Save