fix(android): polling tick no longer force-syncs controller -- avoids Sonos seek-to-0
android / Build + lint + test (push) Successful in 3m26s
android / Build + lint + test (push) Successful in 3m26s
This commit is contained in:
@@ -534,7 +534,7 @@ class PlayerController @Inject constructor(
|
|||||||
desiredIdx > current.queueIndex &&
|
desiredIdx > current.queueIndex &&
|
||||||
desiredIdx in queueRefs.indices
|
desiredIdx in queueRefs.indices
|
||||||
publishTickIfChanged(
|
publishTickIfChanged(
|
||||||
controller, current, trackChanged, desiredIdx,
|
current, trackChanged, desiredIdx,
|
||||||
effectiveIsPlaying, newPos, newDur, newBuf,
|
effectiveIsPlaying, newPos, newDur, newBuf,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -555,7 +555,6 @@ class PlayerController @Inject constructor(
|
|||||||
|
|
||||||
@Suppress("LongParameterList") // assembled at one tick call site; refactor would cost clarity
|
@Suppress("LongParameterList") // assembled at one tick call site; refactor would cost clarity
|
||||||
private fun publishTickIfChanged(
|
private fun publishTickIfChanged(
|
||||||
controller: MediaController,
|
|
||||||
current: PlayerUiState,
|
current: PlayerUiState,
|
||||||
trackChanged: Boolean,
|
trackChanged: Boolean,
|
||||||
desiredIdx: Int,
|
desiredIdx: Int,
|
||||||
@@ -579,11 +578,14 @@ class PlayerController @Inject constructor(
|
|||||||
durationMs = newDur,
|
durationMs = newDur,
|
||||||
bufferedPositionMs = newBuf,
|
bufferedPositionMs = newBuf,
|
||||||
)
|
)
|
||||||
if (trackChanged && controller.currentMediaItemIndex != desiredIdx) {
|
// Intentionally do NOT call controller.seekTo here. That would route
|
||||||
// Defense in depth: keep wrapped player aligned even when
|
// through MinstrelForwardingPlayer's seekTo override and re-issue
|
||||||
// maybeSyncLocalCursor's seekTo didn't fire a transition event.
|
// AVTransport.SeekToTrack to Sonos -- which seeks Sonos back to the
|
||||||
controller.seekTo(desiredIdx, 0L)
|
// start of the same track it's already playing, restarting the song.
|
||||||
}
|
// The wrapped player's index is kept in sync by maybeSyncLocalCursor's
|
||||||
|
// delegate.seekTo (which bypasses the override). If it lags briefly,
|
||||||
|
// the next pollOnce catches up; the uiState above already reflects
|
||||||
|
// Sonos's truth for the user.
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun desiredQueueIndex(controller: MediaController, upnpActive: Boolean): Int =
|
private fun desiredQueueIndex(controller: MediaController, upnpActive: Boolean): Int =
|
||||||
|
|||||||
Reference in New Issue
Block a user