Browse Source

Reattach the detached service notification when the app is swiped (if not playing) for it be removed with the application.

housekeeping/remove-warnings
Antoine POPINEAU 4 years ago
parent
commit
b6b9e4c053
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
  1. 13
      app/src/main/java/com/github/apognu/otter/playback/PlayerService.kt

13
app/src/main/java/com/github/apognu/otter/playback/PlayerService.kt

@ -217,6 +217,16 @@ class PlayerService : Service() { @@ -217,6 +217,16 @@ class PlayerService : Service() {
override fun onBind(intent: Intent?): IBinder? = null
override fun onTaskRemoved(rootIntent: Intent?) {
super.onTaskRemoved(rootIntent)
if (!player.playWhenReady) {
mediaControlsManager.updateNotification(queue.current(), false)
stopSelf()
}
}
@SuppressLint("NewApi")
override fun onDestroy() {
scope.cancel()
@ -243,9 +253,6 @@ class PlayerService : Service() { @@ -243,9 +253,6 @@ class PlayerService : Service() {
setPlaybackState(false)
player.release()
stopForeground(true)
stopSelf()
super.onDestroy()
}

Loading…
Cancel
Save