fix: indexing of beat annotations after unpaired tracks
This commit is contained in:
@@ -192,7 +192,7 @@ class LockstepViewModel(
|
||||
context = appContext,
|
||||
sessionFolder = sessionFolder,
|
||||
playlistDisplayName = playlistDisplayName,
|
||||
trackQueueIndex0Based = event.queueIndex,
|
||||
trackQueueIndex0Based = event.playlistPosition,
|
||||
contentId = contentId,
|
||||
title = event.title,
|
||||
artist = event.artist,
|
||||
@@ -207,7 +207,7 @@ class LockstepViewModel(
|
||||
BeatAnnotationStorage.writeBeatsFile(
|
||||
context = appContext,
|
||||
playlistDisplayName = playlistDisplayName,
|
||||
trackQueueIndex0Based = event.queueIndex,
|
||||
trackQueueIndex0Based = event.playlistPosition,
|
||||
contentId = contentId,
|
||||
title = event.title,
|
||||
artist = event.artist,
|
||||
@@ -278,7 +278,7 @@ class LockstepViewModel(
|
||||
writeRunDataAndRecordMetadata(
|
||||
runSessionFolder = runSessionFolder,
|
||||
playlistDisplayName = playlistDisplayName,
|
||||
trackQueueIndex0Based = event.queueIndex,
|
||||
trackQueueIndex0Based = event.playlistPosition,
|
||||
trackId = event.trackId,
|
||||
metaContentUri = meta,
|
||||
title = event.title,
|
||||
@@ -296,7 +296,7 @@ class LockstepViewModel(
|
||||
trackId: String,
|
||||
title: String,
|
||||
artist: String,
|
||||
queueIndex: Int,
|
||||
playlistPosition: Int,
|
||||
snapshot: RunTrackDataSnapshot,
|
||||
) {
|
||||
if (snapshot.isEmpty()) {
|
||||
@@ -308,7 +308,7 @@ class LockstepViewModel(
|
||||
writeRunDataAndRecordMetadata(
|
||||
runSessionFolder = runSessionFolder,
|
||||
playlistDisplayName = playlistDisplayName,
|
||||
trackQueueIndex0Based = queueIndex,
|
||||
trackQueueIndex0Based = playlistPosition,
|
||||
trackId = trackId,
|
||||
metaContentUri = meta,
|
||||
title = title,
|
||||
|
||||
@@ -110,6 +110,7 @@ class PlaybackService : Service() {
|
||||
title = item.title,
|
||||
artist = item.artist,
|
||||
queueIndex = i,
|
||||
playlistPosition = item.playlistPosition,
|
||||
queueSize = queue.size,
|
||||
reason = reason,
|
||||
),
|
||||
@@ -265,6 +266,7 @@ class PlaybackService : Service() {
|
||||
artist = row.artistName ?: "—",
|
||||
localUri = Uri.parse(uriStr),
|
||||
durationMsHint = hint,
|
||||
playlistPosition = row.position,
|
||||
)
|
||||
}
|
||||
index = 0
|
||||
@@ -300,6 +302,7 @@ class PlaybackService : Service() {
|
||||
isPlaying = _uiState.value.isPlaying,
|
||||
currentTrackId = item.id,
|
||||
currentQueueIndex = index,
|
||||
currentPlaylistPosition = item.playlistPosition,
|
||||
queueSize = queue.size,
|
||||
)
|
||||
updateProgressFromEngine()
|
||||
@@ -367,6 +370,8 @@ class PlaybackService : Service() {
|
||||
durationSeconds = durationSec,
|
||||
currentTrackId = queue.getOrNull(index)?.id ?: _uiState.value.currentTrackId,
|
||||
currentQueueIndex = index,
|
||||
currentPlaylistPosition =
|
||||
queue.getOrNull(index)?.playlistPosition ?: _uiState.value.currentPlaylistPosition,
|
||||
queueSize = queue.size,
|
||||
)
|
||||
updatePlaybackStateFromEngine()
|
||||
@@ -566,6 +571,8 @@ class PlaybackService : Service() {
|
||||
val isPlaying: Boolean,
|
||||
val currentTrackId: String?,
|
||||
val currentQueueIndex: Int,
|
||||
/** 0-based position in the full Spotify playlist for the current track. */
|
||||
val currentPlaylistPosition: Int,
|
||||
val queueSize: Int,
|
||||
) {
|
||||
companion object {
|
||||
@@ -578,6 +585,7 @@ class PlaybackService : Service() {
|
||||
isPlaying = false,
|
||||
currentTrackId = null,
|
||||
currentQueueIndex = 0,
|
||||
currentPlaylistPosition = 0,
|
||||
queueSize = 0,
|
||||
)
|
||||
}
|
||||
@@ -590,6 +598,8 @@ class PlaybackService : Service() {
|
||||
val localUri: Uri?,
|
||||
/** Fallback when the engine has not reported duration yet (from jukebox or default). */
|
||||
val durationMsHint: Int,
|
||||
/** 0-based position in the full Spotify playlist. */
|
||||
val playlistPosition: Int,
|
||||
)
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -8,8 +8,10 @@ data class TrackBoundaryEvent(
|
||||
val trackId: String,
|
||||
val title: String,
|
||||
val artist: String,
|
||||
/** 0-based index in the current play queue when this track was current. */
|
||||
/** 0-based index in the paired-only play queue when this track was current. */
|
||||
val queueIndex: Int,
|
||||
/** 0-based position in the full Spotify playlist (used for beat/run-data file slots). */
|
||||
val playlistPosition: Int,
|
||||
val queueSize: Int,
|
||||
val reason: TrackBoundaryReason,
|
||||
)
|
||||
|
||||
@@ -196,7 +196,7 @@ fun NowPlayingRoute(
|
||||
}
|
||||
var playlistDisplayName by remember { mutableStateOf("playlist") }
|
||||
var currentTrackId by remember { mutableStateOf<String?>(null) }
|
||||
var currentQueueIndex by remember { mutableIntStateOf(0) }
|
||||
var currentPlaylistPosition by remember { mutableIntStateOf(0) }
|
||||
|
||||
var ui by remember {
|
||||
mutableStateOf(
|
||||
@@ -221,7 +221,7 @@ fun NowPlayingRoute(
|
||||
val service = playback ?: return@LaunchedEffect
|
||||
service.uiState.collect { p ->
|
||||
currentTrackId = p.currentTrackId
|
||||
currentQueueIndex = p.currentQueueIndex
|
||||
currentPlaylistPosition = p.currentPlaylistPosition
|
||||
ui =
|
||||
NowPlayingUiState(
|
||||
title = p.title,
|
||||
@@ -285,7 +285,7 @@ fun NowPlayingRoute(
|
||||
trackId = trackId,
|
||||
title = ui.title,
|
||||
artist = ui.artist,
|
||||
queueIndex = currentQueueIndex,
|
||||
playlistPosition = currentPlaylistPosition,
|
||||
snapshot = snapshot,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user