|
|
@ -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) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|