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:
1 parent
3d8c049226
commit
61fa05da93
3 files changed
+41
-6
No files matched your search
@@ -164,6 +164,29 @@ impl QueueManager {
|
||||
|
||||
// Regenerate shuffle order
|
||||
Self::regenerate_shuffle_order_internal(&mut state);
|
||||
|
||||
// CRITICAL FIX: When shuffle is enabled and we have a start_index,
|
||||
// ensure the start_index track is at the BEGINNING of shuffle order
|
||||
// This fixes the bug where shuffle shows incomplete queue
|
||||
if state.shuffle {
|
||||
if let Some(start_idx) = start_index {
|
||||
if start_idx < state.tracks.len() {
|
||||
// Find where start_idx is in the current shuffle_order
|
||||
if let Some(pos) = state.shuffle_order.iter().position(|&x| x == start_idx) {
|
||||
// Move it to the front by swapping
|
||||
state.shuffle_order.swap(0, pos);
|
||||
// Set shuffle position to 0 so we start from the beginning
|
||||
state.shuffle_position = 0;
|
||||
|
||||
log::info!(
|
||||
"Queue: Adjusted shuffle order to start with track index {} (was at position {})",
|
||||
start_idx,
|
||||
pos
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Clear the queue
|
||||
|
||||
Reference in new issue
Block a user