removing a check for stopping playback

This commit is contained in:
tibbi 2022-07-10 09:57:21 +02:00
parent 889ee5785b
commit 5e656dcab8

View file

@ -497,15 +497,6 @@ class MusicService : Service(), MediaPlayer.OnPreparedListener, MediaPlayer.OnEr
try {
startForeground(NOTIFICATION_ID, notification.build())
// delay foreground state updating a bit, so the notification can be swiped away properly after initial display
Handler(Looper.getMainLooper()).postDelayed({
val isFocusLost = mPrevAudioFocusState == AUDIOFOCUS_LOSS || mPrevAudioFocusState == AUDIOFOCUS_LOSS_TRANSIENT
val isPlaybackStoppedAfterFocusLoss = mWasPlayingAtFocusLost && isFocusLost
if (!getIsPlaying() && !isPlaybackStoppedAfterFocusLoss) {
stopForeground(false)
}
}, 200L)
} catch (ignored: ForegroundServiceStartNotAllowedException) {
}
}