From 27e5bfb21627c73b53623c5ccbf93841a221bfb2 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Sat, 7 Nov 2026 12:23:51 +0100 Subject: island: shuffle and repeat as two Sonix buttons The one mode button cycled all five SonixLink modes and showed repeat-off as its first state, so shuffle looked missing. Shuffle is now a toggle on the left and repeat a cycle on the right. SonixLink has no shuffle with repeat one, so with shuffle on repeat goes off and all only. Co-Authored-By: Claude Opus 5.5 --- desktop/modules/sonix/Sonix.js | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'desktop/modules/sonix/Sonix.js') diff --git a/desktop/modules/sonix/Sonix.js b/desktop/modules/sonix/Sonix.js index d4330ce..55b8ac4 100644 --- a/desktop/modules/sonix/Sonix.js +++ b/desktop/modules/sonix/Sonix.js @@ -39,12 +39,29 @@ function qualityLine(s) { return parts.join(" ยท "); } -const MODES = ["normal", "repeat_all", "repeat_one", "shuffle", "shuffle_repeat"]; -// md-repeat_off, md-repeat, md-repeat_once, md-shuffle, md-shuffle (with repeat) -const MODE_GLYPHS = [0xF0457, 0xF0456, 0xF0458, 0xF049D, 0xF049D]; +// SonixLink has one playback mode out of five; the panel shows it as a +// shuffle toggle and a repeat cycle. There is no shuffle with repeat one, so +// with shuffle on repeat only goes off and all, and turning shuffle on from +// repeat one drops the repeat. +function shuffled(m) { return m === "shuffle" || m === "shuffle_repeat"; } + +function toggleShuffle(m) { + if (m === "shuffle") return "normal"; + if (m === "shuffle_repeat") return "repeat_all"; + return m === "repeat_all" ? "shuffle_repeat" : "shuffle"; +} + +function nextRepeat(m) { + if (shuffled(m)) return m === "shuffle" ? "shuffle_repeat" : "shuffle"; + return m === "repeat_all" ? "repeat_one" : m === "repeat_one" ? "normal" : "repeat_all"; +} -function nextMode(m) { return MODES[(MODES.indexOf(m) + 1) % MODES.length]; } -function modeGlyph(m) { return MODE_GLYPHS[Math.max(0, MODES.indexOf(m))]; } +// md-shuffle / md-shuffle_disabled +function shuffleGlyph(m) { return shuffled(m) ? 0xF049D : 0xF049E; } +// md-repeat / md-repeat_once / md-repeat_off +function repeatGlyph(m) { + return m === "repeat_all" || m === "shuffle_repeat" ? 0xF0456 : m === "repeat_one" ? 0xF0458 : 0xF0457; +} function clock(sec) { sec = Math.max(0, Math.floor(sec)); -- cgit v1.2.3