Fix critical shuffle queue bug, Local Library context, and sample rate crash

1. QUEUE SHUFFLE FIX (CRITICAL):
   - When shuffle enabled and set_queue called, starting track was placed randomly in shuffle_order
   - This caused queue UI to show only tracks AFTER that random position
   - Example: 11 tracks, start at index 5, but index 5 was at position 7 in shuffle → only 3 tracks visible
   - FIX: When shuffle enabled, swap starting track to position 0 in shuffle_order
   - Now all tracks appear in queue UI as expected

2. LOCAL LIBRARY CONTEXT FIX:
   - handleLocalTrackPlay was clearing context immediately after LocalLibraryView set it
   - FIX: Removed clearPlaybackContext() call - LocalLibraryView handles context correctly
   - Context icon should now display for Local Library playback

3. SAMPLE RATE CRASH FIX:
   - show_track_notification expected u32 but received f64 (44.1, 88.2, etc.)
   - Error: "invalid type: floating point 44.1, expected u32"
   - FIX: Changed sample_rate parameter from u32 to f64 in notification command and format_quality
   - Bonus: Format shows "44.1" for fractional rates, "48" for whole numbers

Files modified:
- src-tauri/src/queue/mod.rs - Fixed set_queue to move start_index to front of shuffle_order
- src/routes/+page.svelte - Removed clearPlaybackContext from handleLocalTrackPlay
- src-tauri/src/commands/notification.rs - Changed sample_rate to f64 with proper formatting
This commit is contained in:
vicrodh committed 2026-01-19 19:13:07 -06:00
1 parent 3d8c049226
commit 61fa05da93
3 files changed
+41 -6

No files matched your search

+2 -1
View File
@@ -1363,7 +1363,8 @@
async function handleLocalTrackPlay(track: LocalLibraryTrack) {
console.log('Playing local track:', track);
await clearPlaybackContext();
// DO NOT clear context - LocalLibraryView already sets it correctly
// await clearPlaybackContext();
const artwork = track.artwork_path ? convertFileSrc(track.artwork_path) : '';
const quality = track.bit_depth && track.sample_rate