pull/34/head
kunfei 5 years ago
parent a2fa8e1adb
commit 5a3224f55f
  1. 7
      app/src/main/java/io/legado/app/service/ReadAloudService.kt

@ -345,12 +345,13 @@ class ReadAloudService : BaseService(), TextToSpeech.OnInitListener,
mediaSessionCompat?.isActive = true mediaSessionCompat?.isActive = true
} }
/**
* 断开耳机监听
*/
private fun initBroadcastReceiver() { private fun initBroadcastReceiver() {
//断开耳机监听
broadcastReceiver = object : BroadcastReceiver() { broadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) { override fun onReceive(context: Context, intent: Intent) {
val action = intent.action if (AudioManager.ACTION_AUDIO_BECOMING_NOISY == intent.action) {
if (AudioManager.ACTION_AUDIO_BECOMING_NOISY == action) {
pauseReadAloud(true) pauseReadAloud(true)
} }
} }

Loading…
Cancel
Save