playback: fix more state restore issues
They just keep coming. I hate how complicated this system is.
This commit is contained in:
parent
2f36fcfb45
commit
2a0624f860
3 changed files with 9 additions and 7 deletions
|
@ -470,8 +470,9 @@ constructor(
|
||||||
ack?.let { playbackManager.ack(this, it) }
|
ack?.let { playbackManager.ack(this, it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun reset() {
|
override fun reset(ack: StateAck.NewPlayback) {
|
||||||
player.setMediaItems(emptyList())
|
player.setMediaItems(emptyList())
|
||||||
|
playbackManager.ack(this, ack)
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- PLAYER OVERRIDES ---
|
// --- PLAYER OVERRIDES ---
|
||||||
|
|
|
@ -155,7 +155,7 @@ interface PlaybackStateHolder {
|
||||||
fun applySavedState(parent: MusicParent?, rawQueue: RawQueue, ack: StateAck.NewPlayback?)
|
fun applySavedState(parent: MusicParent?, rawQueue: RawQueue, ack: StateAck.NewPlayback?)
|
||||||
|
|
||||||
/** Reset this instance to an empty state. */
|
/** Reset this instance to an empty state. */
|
||||||
fun reset()
|
fun reset(ack: StateAck.NewPlayback)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -743,19 +743,20 @@ class PlaybackStateManagerImpl @Inject constructor() : PlaybackStateManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we re-align the index to point to the previously playing song.
|
// Make sure we re-align the index to point to the previously playing song.
|
||||||
fun pointingAtSong(): Boolean {
|
fun pointingAtSong(index: Int): Boolean {
|
||||||
val currentSong =
|
val currentSong =
|
||||||
if (shuffledMapping.isNotEmpty()) {
|
if (shuffledMapping.isNotEmpty()) {
|
||||||
shuffledMapping.getOrNull(savedState.index)?.let { heap.getOrNull(it) }
|
shuffledMapping.getOrNull(index)?.let { heap.getOrNull(it) }
|
||||||
} else {
|
} else {
|
||||||
heap.getOrNull(savedState.index)
|
heap.getOrNull(index)
|
||||||
}
|
}
|
||||||
|
logD(currentSong)
|
||||||
|
|
||||||
return currentSong?.uid == savedState.songUid
|
return currentSong?.uid == savedState.songUid
|
||||||
}
|
}
|
||||||
|
|
||||||
var index = savedState.index
|
var index = savedState.index
|
||||||
while (!pointingAtSong() && index > -1) {
|
while (!pointingAtSong(index) && index > -1) {
|
||||||
index--
|
index--
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -766,7 +767,7 @@ class PlaybackStateManagerImpl @Inject constructor() : PlaybackStateManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
stateHolder.reset()
|
stateHolder.reset(StateAck.NewPlayback)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue