Merge pull request #228 from Sietse2202/patch-1
fix(player): Uniform shuffle
This commit is contained in:
commit
8cd9f782ba
1 changed files with 4 additions and 1 deletions
|
|
@ -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];
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue