Merge pull request #228 from Sietse2202/patch-1

fix(player): Uniform shuffle
This commit is contained in:
Samidy 2026-02-21 22:58:37 +03:00 committed by GitHub
commit 8cd9f782ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -681,7 +681,10 @@ export class Player {
tracksToShuffle.splice(this.currentQueueIndex, 1); tracksToShuffle.splice(this.currentQueueIndex, 1);
} }
tracksToShuffle.sort(() => Math.random() - 0.5); for (let i = tracksToShuffle.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[tracksToShuffle[i], tracksToShuffle[j]] = [tracksToShuffle[j], tracksToShuffle[i]];
}
if (currentTrack) { if (currentTrack) {
this.shuffledQueue = [currentTrack, ...tracksToShuffle]; this.shuffledQueue = [currentTrack, ...tracksToShuffle];