mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 16:00:31 +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 {
|
player!!.addListener(object : Player.Listener {
|
||||||
override fun onPlaybackStateChanged(@Player.State state: Int) {
|
override fun onPlaybackStateChanged(@Player.State state: Int) {
|
||||||
val autoplay = PreferenceHelper.getBoolean(PreferenceKeys.AUTO_PLAY, false)
|
when (state) {
|
||||||
if (state == Player.STATE_ENDED) {
|
Player.STATE_ENDED -> {
|
||||||
if (autoplay) playNextVideo()
|
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…
x
Reference in New Issue
Block a user