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.ExoPlaybackStateHolder
|
||||||
import org.oxycblt.auxio.playback.service.SystemPlaybackReceiver
|
import org.oxycblt.auxio.playback.service.SystemPlaybackReceiver
|
||||||
import org.oxycblt.auxio.playback.state.PlaybackStateManager
|
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.playback.state.RepeatMode
|
||||||
import org.oxycblt.auxio.util.getSystemServiceCompat
|
import org.oxycblt.auxio.util.getSystemServiceCompat
|
||||||
import org.oxycblt.auxio.util.logD
|
import org.oxycblt.auxio.util.logD
|
||||||
|
|
@ -232,10 +233,6 @@ class AuxioService :
|
||||||
// --- INTERNAL ---
|
// --- INTERNAL ---
|
||||||
|
|
||||||
private fun updateForeground(forMusic: Boolean) {
|
private fun updateForeground(forMusic: Boolean) {
|
||||||
if (playbackManager.progression.isPlaying) {
|
|
||||||
inPlayback = true
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inPlayback) {
|
if (inPlayback) {
|
||||||
if (!forMusic) {
|
if (!forMusic) {
|
||||||
val notification =
|
val notification =
|
||||||
|
|
@ -287,7 +284,7 @@ class AuxioService :
|
||||||
} else {
|
} else {
|
||||||
// Not observing and done loading, exit foreground.
|
// Not observing and done loading, exit foreground.
|
||||||
logD("Exiting 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)
|
// Release our wake lock (if we were using it)
|
||||||
wakeLock.releaseSafe()
|
wakeLock.releaseSafe()
|
||||||
|
|
@ -500,9 +497,11 @@ class AuxioService :
|
||||||
updateCustomButtons()
|
updateCustomButtons()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onQueueReordered(queue: List<Song>, index: Int, isShuffled: Boolean) {
|
override fun onProgressionChanged(progression: Progression) {
|
||||||
super.onQueueReordered(queue, index, isShuffled)
|
super.onProgressionChanged(progression)
|
||||||
updateCustomButtons()
|
if (progression.isPlaying) {
|
||||||
|
inPlayback = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onRepeatModeChanged(repeatMode: RepeatMode) {
|
override fun onRepeatModeChanged(repeatMode: RepeatMode) {
|
||||||
|
|
@ -510,6 +509,11 @@ class AuxioService :
|
||||||
updateCustomButtons()
|
updateCustomButtons()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onQueueReordered(queue: List<Song>, index: Int, isShuffled: Boolean) {
|
||||||
|
super.onQueueReordered(queue, index, isShuffled)
|
||||||
|
updateCustomButtons()
|
||||||
|
}
|
||||||
|
|
||||||
override fun onNotificationActionChanged() {
|
override fun onNotificationActionChanged() {
|
||||||
super.onNotificationActionChanged()
|
super.onNotificationActionChanged()
|
||||||
updateCustomButtons()
|
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.PlaybackStateManager
|
||||||
import org.oxycblt.auxio.playback.state.RepeatMode
|
import org.oxycblt.auxio.playback.state.RepeatMode
|
||||||
import org.oxycblt.auxio.playback.state.ShuffleMode
|
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
|
* 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.
|
* and routes them to PlaybackStateManager so I know that they will work the way I want it to.
|
||||||
|
*
|
||||||
* @author Alexander Capehart
|
* @author Alexander Capehart
|
||||||
*/
|
*/
|
||||||
class MediaSessionPlayer(
|
class MediaSessionPlayer(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue