pull/2287/head 3.22.091520
kunfei 2 years ago
parent 7685360e08
commit 346807155a
  1. 12
      app/src/main/java/io/legado/app/service/BaseReadAloudService.kt

@ -278,21 +278,29 @@ abstract class BaseReadAloudService : BaseService(),
override fun onAudioFocusChange(focusChange: Int) {
when (focusChange) {
AudioManager.AUDIOFOCUS_GAIN -> {
audioFocusLossTransient = false
if (!pause) resumeReadAloud()
if (!pause) {
AppLog.put("音频焦点获得,继续朗读")
resumeReadAloud()
} else {
AppLog.put("音频焦点获得")
}
}
AudioManager.AUDIOFOCUS_LOSS -> {
AppLog.put("音频焦点丢失,暂停朗读")
if (audioFocusLossTransient) {
pauseReadAloud(true)
}
}
AudioManager.AUDIOFOCUS_LOSS_TRANSIENT -> {
AppLog.put("音频焦点暂时丢失并会很快再次获得,暂停朗读")
audioFocusLossTransient = true
if (!pause) pauseReadAloud(false)
}
AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK -> {
// 短暂丢失焦点,这种情况是被其他应用申请了短暂的焦点希望其他声音能压低音量(或者关闭声音)凸显这个声音(比如短信提示音),
AppLog.put("短暂丢失焦点,不做处理")
AppLog.put("音频焦点短暂丢失,不做处理")
}
}
}

Loading…
Cancel
Save