aboutsummaryrefslogtreecommitdiffstats
path: root/src/queue.rs
diff options
context:
space:
mode:
authorsalmonik <raisersoft@proton.me>2026-05-08 01:12:31 +0200
committersalmonik <raisersoft@proton.me>2026-05-08 01:12:31 +0200
commit0f00616dca071750381234b5c59c8ec1e71b28ed (patch)
tree35d01b2ea8bbff458df5cb39ccc7d7b5dc6640ae /src/queue.rs
parentAdd desktop notifications for track changes, queue end, and errors (diff)
downloadrsplayer-0f00616dca071750381234b5c59c8ec1e71b28ed.tar.gz
rsplayer-0f00616dca071750381234b5c59c8ec1e71b28ed.zip
Fix shuffle first song not being shuffled
update_shuffle_indices now shuffles all indices when position is 0 (no tracks have been played yet), so the first track played is random instead of always being tracks[0]. Directory playback now uses q.current() to pick the first track, resolving through shuffled indices when shuffle is active. Also pins notify-rust version in Cargo.toml and removes PLAN.md (superseded by TODO.md).
Diffstat (limited to 'src/queue.rs')
-rw-r--r--src/queue.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/queue.rs b/src/queue.rs
index 53b104f..dca8e3d 100644
--- a/src/queue.rs
+++ b/src/queue.rs
@@ -171,7 +171,9 @@ impl Queue {
171 if let ShuffleMode::All = self.shuffle { 171 if let ShuffleMode::All = self.shuffle {
172 let mut rng = rand::rng(); 172 let mut rng = rand::rng();
173 let pos = self.position.min(len.saturating_sub(1)); 173 let pos = self.position.min(len.saturating_sub(1));
174 if pos + 1 < len { 174 if pos == 0 && len > 1 {
175 self.shuffled_indices.shuffle(&mut rng);
176 } else if pos + 1 < len {
175 self.shuffled_indices[pos + 1..].shuffle(&mut rng); 177 self.shuffled_indices[pos + 1..].shuffle(&mut rng);
176 } 178 }
177 } 179 }