playback: fix being unable to exit fg

This commit is contained in:
Alexander Capehart 2024-04-10 19:30:49 -06:00
parent a6cc38e43c
commit 74551e83ab
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
2 changed files with 13 additions and 9 deletions

View file

@ -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()

View file

@ -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(