mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 14:20:30 +05:30
kill background play properly
This commit is contained in:
parent
a6cd8a8c12
commit
05ad4363ff
@ -142,9 +142,18 @@ class BackgroundMode : Service() {
|
||||
*/
|
||||
player!!.addListener(object : Player.Listener {
|
||||
override fun onPlaybackStateChanged(@Player.State state: Int) {
|
||||
val autoplay = PreferenceHelper.getBoolean(PreferenceKeys.AUTO_PLAY, false)
|
||||
if (state == Player.STATE_ENDED) {
|
||||
if (autoplay) playNextVideo()
|
||||
when (state) {
|
||||
Player.STATE_ENDED -> {
|
||||
val autoplay = PreferenceHelper.getBoolean(PreferenceKeys.AUTO_PLAY, true)
|
||||
if (autoplay) playNextVideo()
|
||||
}
|
||||
Player.STATE_IDLE -> {
|
||||
// called when the user pressed stop in the notification
|
||||
// stop the service from being in the foreground and remove the notification
|
||||
stopForeground(true)
|
||||
// destroy the service
|
||||
stopSelf()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user