@ -185,7 +185,10 @@ class PlayerService : Service() {
@@ -185,7 +185,10 @@ class PlayerService : Service() {
is Command . PreviousTrack -> skipToPreviousTrack ( )
is Command . Seek -> seek ( command . progress )
is Command . ClearQueue -> queue . clear ( )
is Command . ClearQueue -> {
queue . clear ( )
player . stop ( )
}
is Command . ShuffleQueue -> queue . shuffle ( )
is Command . PlayRadio -> {
@ -389,7 +392,20 @@ class PlayerService : Service() {
@@ -389,7 +392,20 @@ class PlayerService : Service() {
when ( playbackState ) {
Player . STATE _READY -> mediaControlsManager . updateNotification ( queue . current ( ) , true )
Player . STATE _BUFFERING -> EventBus . send ( Event . Buffering ( true ) )
Player . STATE _ENDED -> EventBus . send ( Event . PlaybackStopped )
Player . STATE _ENDED -> {
setPlaybackState ( false )
queue . current = 0
player . seekTo ( 0 , C . TIME _UNSET )
ProgressBus . send ( 0 , 0 , 0 )
}
Player . STATE _IDLE -> {
setPlaybackState ( false )
return EventBus . send ( Event . PlaybackStopped )
}
}
if ( playbackState != Player . STATE _BUFFERING ) EventBus . send ( Event . Buffering ( false ) )
@ -398,13 +414,14 @@ class PlayerService : Service() {
@@ -398,13 +414,14 @@ class PlayerService : Service() {
false -> {
EventBus . send ( Event . Buffering ( false ) )
if ( playbackState == Player . STATE _READY ) {
mediaControlsManager . updateNotification ( queue . current ( ) , false )
Build . VERSION _CODES . N . onApi (
{ stopForeground ( STOP _FOREGROUND _DETACH ) } ,
{ stopForeground ( false ) }
)
when ( playbackState ) {
Player . STATE _READY -> mediaControlsManager . updateNotification ( queue . current ( ) , false )
Player . STATE _IDLE -> mediaControlsManager . remove ( )
}
}
}