fix: Improve radio playback and session handling
- Fix radio playback initiation using onTrackPlay callback - Fix sampling rate display for Qobuz tracks (already in kHz) - Disable session restore to prevent local/Qobuz ID conflicts
This commit is contained in:
1 parent
484c27417a
commit
240c5e013a
2 files changed
+47
-7
No files matched your search
@@ -6,7 +6,7 @@
|
||||
import TrackMenu from '../TrackMenu.svelte';
|
||||
import { consumeContextTrackFocus, setPlaybackContext } from '$lib/stores/playbackContextStore';
|
||||
import { togglePlay } from '$lib/stores/playerStore';
|
||||
import { playQueueIndex } from '$lib/stores/queueStore';
|
||||
import { getQueue } from '$lib/stores/queueStore';
|
||||
import { tick } from 'svelte';
|
||||
|
||||
interface Track {
|
||||
@@ -260,8 +260,26 @@
|
||||
});
|
||||
console.log(`[Radio] Artist radio created: ${sessionId}`);
|
||||
|
||||
// Start playing the first track from the radio queue
|
||||
await playQueueIndex(0);
|
||||
// Get the first track from queue and start playback
|
||||
const queue = getQueue();
|
||||
|
||||
if (queue.length > 0 && onTrackPlay) {
|
||||
const firstTrack = queue[0];
|
||||
// Start playback using the onTrackPlay callback
|
||||
onTrackPlay({
|
||||
id: Number(firstTrack.id),
|
||||
title: firstTrack.title,
|
||||
artist: firstTrack.artist,
|
||||
album: firstTrack.album,
|
||||
albumArt: firstTrack.artwork_url || '',
|
||||
duration: formatDuration(firstTrack.duration_secs),
|
||||
durationSeconds: firstTrack.duration_secs,
|
||||
hires: firstTrack.hires,
|
||||
bitDepth: firstTrack.bit_depth ?? undefined,
|
||||
samplingRate: firstTrack.sample_rate ?? undefined,
|
||||
});
|
||||
console.log(`[Radio] Started playback of track ${firstTrack.id}`);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to create artist radio:', err);
|
||||
// TODO: Show user-facing error toast if available
|
||||
@@ -282,8 +300,26 @@
|
||||
});
|
||||
console.log(`[Radio] Track radio created: ${sessionId}`);
|
||||
|
||||
// Start playing the first track from the radio queue
|
||||
await playQueueIndex(0);
|
||||
// Get the first track from queue and start playback
|
||||
const queue = getQueue();
|
||||
|
||||
if (queue.length > 0 && onTrackPlay) {
|
||||
const firstTrack = queue[0];
|
||||
// Start playback using the onTrackPlay callback
|
||||
onTrackPlay({
|
||||
id: Number(firstTrack.id),
|
||||
title: firstTrack.title,
|
||||
artist: firstTrack.artist,
|
||||
album: firstTrack.album,
|
||||
albumArt: firstTrack.artwork_url || '',
|
||||
duration: formatDuration(firstTrack.duration_secs),
|
||||
durationSeconds: firstTrack.duration_secs,
|
||||
hires: firstTrack.hires,
|
||||
bitDepth: firstTrack.bit_depth ?? undefined,
|
||||
samplingRate: firstTrack.sample_rate ?? undefined,
|
||||
});
|
||||
console.log(`[Radio] Started playback of track ${firstTrack.id}`);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to create track radio:', err);
|
||||
// TODO: Show user-facing error toast if available
|
||||
|
||||
@@ -939,7 +939,8 @@
|
||||
duration: track.duration_secs,
|
||||
quality,
|
||||
bitDepth: track.bit_depth ?? undefined,
|
||||
samplingRate: track.sample_rate ? track.sample_rate / 1000 : undefined, // Convert Hz to kHz (44100 → 44.1)
|
||||
// Only convert Hz to kHz for local tracks. Qobuz tracks are already in kHz.
|
||||
samplingRate: isLocal && track.sample_rate ? track.sample_rate / 1000 : track.sample_rate ?? undefined,
|
||||
isLocal
|
||||
}, { isLocal, showLoadingToast: false });
|
||||
}
|
||||
@@ -1496,7 +1497,9 @@
|
||||
console.debug('[Reco] Score training failed:', err);
|
||||
});
|
||||
|
||||
// Restore previous session if available
|
||||
// DISABLED: Restore previous session if available
|
||||
// (Temporarily disabled due to ID conflicts between local and Qobuz tracks)
|
||||
/*
|
||||
try {
|
||||
const session = await loadSessionState();
|
||||
if (session && session.queue_tracks.length > 0) {
|
||||
@@ -1584,6 +1587,7 @@
|
||||
} catch (err) {
|
||||
console.error('[Session] Failed to restore session:', err);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
async function handleLogout() {
|
||||
|
||||
Reference in new issue
Block a user