fix(player): pass durationSecs on session-restore first play so seekbar advances

Root cause traced from user diagnostic: only one playback:state event
fired (position=0), then nothing. Backend's current_position() returned
0 forever because thread_state.duration was 0 — the PlayStreaming
handler at player/mod.rs:1849 stores duration verbatim from the
command parameter and current_position() at player/mod.rs:789 ends
with .min(duration), clamping to 0.

Parameter names also didn't line up. cmdPlayTrack was invoking
v2_play_track with qualityStr and lowQualityFallback, neither of
which matches Tauri's camelCase mapping of the Rust signature
(quality, forceLowestQuality, durationSecs). Quality and force-fallback
were being silently ignored; durationSecs was never sent at all.

The normal queue playback path in playbackService uses the correct
camelCase names and passes track.duration, which is why the seekbar
worked everywhere except the session-restore first play — that path
goes through togglePlayback → cmdPlayTrack.

Fix:
- Correct the parameter names in cmdPlayTrack to match the backend
  (quality, forceLowestQuality, durationSecs).
- Add durationSecs as a first-class arg and pass it from
  togglePlayback when resuming a restored track.
- Drop the temporary [Diag:*] console logs added while investigating.

cc
This commit is contained in:
vicrodh committed 2026-04-14 18:57:20 -06:00
1 parent 77d54f99d2
commit 6094876aa1
3 files changed
+22 -11

No files matched your search

+13 -2
View File
@@ -103,13 +103,24 @@ export async function cmdPrevious(): Promise<unknown> {
export async function cmdPlayTrack(
trackId: number,
quality?: string,
lowQualityFallback?: unknown,
durationSecs?: number | null,
forceLowestQuality?: boolean | null,
): Promise<unknown> {
const target = getTarget();
if (target.type === 'qbzd') {
return remotePost('/api/playback/play-track', { track_id: trackId, quality });
} else {
return invoke('v2_play_track', { trackId, qualityStr: quality, lowQualityFallback: lowQualityFallback ?? null });
// Parameter names MUST match Tauri's camelCase mapping of Rust
// v2_play_track(track_id, quality, force_lowest_quality, duration_secs).
// duration_secs is required on the streaming path — without it the
// backend stores duration=0 and current_position() clamps to 0,
// freezing the seekbar (seen on session-restore first play).
return invoke('v2_play_track', {
trackId,
quality: quality ?? null,
forceLowestQuality: forceLowestQuality ?? null,
durationSecs: durationSecs ?? null,
});
}
}
+9 -2
View File
@@ -428,8 +428,15 @@ export async function togglePlay(): Promise<void> {
const localTrackId = Math.abs(currentTrack.id);
await invoke('v2_library_play_track', { trackId: localTrackId });
} else {
// Qobuz track - use v2_play_track
await cmdPlayTrack(currentTrack.id, getStreamingQuality());
// Qobuz track - use v2_play_track. Pass duration so the
// streaming backend's current_position() doesn't clamp to 0
// (the value flows into thread_state.duration and seekbar
// progress is capped by .min(duration)).
await cmdPlayTrack(
currentTrack.id,
getStreamingQuality(),
currentTrack.duration ? Math.round(currentTrack.duration) : null,
);
}
} else {
-7
View File
@@ -1375,13 +1375,6 @@
showToast($t('toast.loadingAlbum'), 'info');
const album = await invoke<QobuzAlbum>('v2_get_album', { albumId });
// DEBUG: full album payload from /album/get (including awards) so
// we can see exactly what Qobuz returns for each field.
console.log('[AlbumView] /album/get raw response:', JSON.parse(JSON.stringify(album)));
if (album.awards) {
console.log('[AlbumView] awards array:', JSON.parse(JSON.stringify(album.awards)));
}
const converted = convertQobuzAlbum(album);
if (!converted || !converted.id) {