Skip to content

Commit 84cbf90

Browse files
committed
Fix more issues with media player resuming on pause events
#560
1 parent 2046683 commit 84cbf90

File tree

1 file changed

+6
-6
lines changed
  • app/src/main/kotlin/com/simplemobiletools/musicplayer/helpers

1 file changed

+6
-6
lines changed

app/src/main/kotlin/com/simplemobiletools/musicplayer/helpers/MultiPlayer.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,13 @@ class MultiPlayer(private val app: Application, private val callbacks: PlaybackC
4040
}
4141

4242
AudioManager.AUDIOFOCUS_LOSS -> {
43-
if (isPlaying()) {
44-
pause()
45-
}
43+
pause()
4644
callbacks.onPlayStateChanged()
4745
}
4846

4947
AudioManager.AUDIOFOCUS_LOSS_TRANSIENT -> {
5048
val wasPlaying = isPlaying()
51-
if (wasPlaying) {
52-
pause()
53-
}
49+
pause()
5450
callbacks.onPlayStateChanged()
5551
isPausedByTransientLossOfFocus = wasPlaying
5652
}
@@ -142,6 +138,10 @@ class MultiPlayer(private val app: Application, private val callbacks: PlaybackC
142138
}
143139

144140
fun pause(): Boolean {
141+
if (!isPlaying()) {
142+
return false
143+
}
144+
145145
unregisterBecomingNoisyReceiver()
146146
return try {
147147
mCurrentMediaPlayer.pause()

0 commit comments

Comments
 (0)