Make shuffle reorder and restore the play queue, add off/all/one repeat playback, and remove Resonant Radio UI.
Hop-State: A_06FNNZKG8MKNEJA6QXQ1ZER Hop-Proposal: R_06FNNZJMKS1Z9RBS9ADD3ER Hop-Task: T_06FNNXTJEGA5TEAZ2GA55X0 Hop-Attempt: AT_06FNNXTJEHPH9SQPGKC0P9G
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
export type RepeatMode = "off" | "all" | "one";
|
||||
|
||||
export function nextRepeatMode(mode: RepeatMode): RepeatMode {
|
||||
if (mode === "off") return "all";
|
||||
if (mode === "all") return "one";
|
||||
return "off";
|
||||
}
|
||||
|
||||
export function shuffleTracks<T>(items: readonly T[], random: () => number = Math.random): T[] {
|
||||
const shuffled = [...items];
|
||||
|
||||
for (let index = shuffled.length - 1; index > 0; index -= 1) {
|
||||
const swapIndex = Math.floor(random() * (index + 1));
|
||||
[shuffled[index], shuffled[swapIndex]] = [shuffled[swapIndex], shuffled[index]];
|
||||
}
|
||||
|
||||
return shuffled;
|
||||
}
|
||||
Reference in New Issue
Block a user