fixed #115
This commit is contained in:
parent
5b31bc0d81
commit
1a99e16af7
2 changed files with 4 additions and 0 deletions
|
@ -3,6 +3,7 @@ package com.simplemobiletools.musicplayer.receivers
|
|||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.media.AudioManager
|
||||
import com.simplemobiletools.musicplayer.extensions.sendIntent
|
||||
import com.simplemobiletools.musicplayer.helpers.PAUSE
|
||||
|
||||
|
@ -15,6 +16,8 @@ class HeadsetPlugReceiver : BroadcastReceiver() {
|
|||
if (state == 0) {
|
||||
context.sendIntent(PAUSE)
|
||||
}
|
||||
} else if (intent.action == AudioManager.ACTION_AUDIO_BECOMING_NOISY) {
|
||||
context.sendIntent(PAUSE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -648,6 +648,7 @@ class MusicService : Service(), MediaPlayer.OnPreparedListener, MediaPlayer.OnEr
|
|||
|
||||
if (isPlaying) {
|
||||
val filter = IntentFilter(Intent.ACTION_HEADSET_PLUG)
|
||||
filter.addAction(AudioManager.ACTION_AUDIO_BECOMING_NOISY)
|
||||
registerReceiver(mHeadsetPlugReceiver, filter)
|
||||
} else {
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue