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