playback: fix being unable to exit fg
This commit is contained in:
parent
a6cc38e43c
commit
74551e83ab
2 changed files with 13 additions and 9 deletions
|
@ -67,6 +67,7 @@ import org.oxycblt.auxio.playback.PlaybackSettings
|
|||
import org.oxycblt.auxio.playback.service.ExoPlaybackStateHolder
|
||||
import org.oxycblt.auxio.playback.service.SystemPlaybackReceiver
|
||||
import org.oxycblt.auxio.playback.state.PlaybackStateManager
|
||||
import org.oxycblt.auxio.playback.state.Progression
|
||||
import org.oxycblt.auxio.playback.state.RepeatMode
|
||||
import org.oxycblt.auxio.util.getSystemServiceCompat
|
||||
import org.oxycblt.auxio.util.logD
|
||||
|
@ -232,10 +233,6 @@ class AuxioService :
|
|||
// --- INTERNAL ---
|
||||
|
||||
private fun updateForeground(forMusic: Boolean) {
|
||||
if (playbackManager.progression.isPlaying) {
|
||||
inPlayback = true
|
||||
}
|
||||
|
||||
if (inPlayback) {
|
||||
if (!forMusic) {
|
||||
val notification =
|
||||
|
@ -287,7 +284,7 @@ class AuxioService :
|
|||
} else {
|
||||
// Not observing and done loading, exit foreground.
|
||||
logD("Exiting foreground")
|
||||
ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_DETACH)
|
||||
ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_REMOVE)
|
||||
}
|
||||
// Release our wake lock (if we were using it)
|
||||
wakeLock.releaseSafe()
|
||||
|
@ -500,9 +497,11 @@ class AuxioService :
|
|||
updateCustomButtons()
|
||||
}
|
||||
|
||||
override fun onQueueReordered(queue: List<Song>, index: Int, isShuffled: Boolean) {
|
||||
super.onQueueReordered(queue, index, isShuffled)
|
||||
updateCustomButtons()
|
||||
override fun onProgressionChanged(progression: Progression) {
|
||||
super.onProgressionChanged(progression)
|
||||
if (progression.isPlaying) {
|
||||
inPlayback = true
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRepeatModeChanged(repeatMode: RepeatMode) {
|
||||
|
@ -510,6 +509,11 @@ class AuxioService :
|
|||
updateCustomButtons()
|
||||
}
|
||||
|
||||
override fun onQueueReordered(queue: List<Song>, index: Int, isShuffled: Boolean) {
|
||||
super.onQueueReordered(queue, index, isShuffled)
|
||||
updateCustomButtons()
|
||||
}
|
||||
|
||||
override fun onNotificationActionChanged() {
|
||||
super.onNotificationActionChanged()
|
||||
updateCustomButtons()
|
||||
|
|
|
@ -44,11 +44,11 @@ import org.oxycblt.auxio.playback.state.PlaybackCommand
|
|||
import org.oxycblt.auxio.playback.state.PlaybackStateManager
|
||||
import org.oxycblt.auxio.playback.state.RepeatMode
|
||||
import org.oxycblt.auxio.playback.state.ShuffleMode
|
||||
import org.oxycblt.auxio.util.logD
|
||||
|
||||
/**
|
||||
* A thin wrapper around the player instance that takes all the events I know MediaSession will send
|
||||
* and routes them to PlaybackStateManager so I know that they will work the way I want it to.
|
||||
*
|
||||
* @author Alexander Capehart
|
||||
*/
|
||||
class MediaSessionPlayer(
|
||||
|
|
Loading…
Reference in a new issue