mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
This commit is contained in:
@@ -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("音频焦点短暂丢失,不做处理")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user