From 542ec03673b31e3120fc5bd4b5e81a01da1ef94a Mon Sep 17 00:00:00 2001 From: ZortexSenpai Date: Sat, 5 Dec 2026 00:13:02 +0100 Subject: [PATCH] feat: added output picker and EQ button setting for the player bar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The player bar can show an output picker: a speaker button beside the volume that switches Device configs without opening Settings. Off by default; turned on in Settings → Audio. - Picker lists System default and every Device config with the same summary as Settings, in red for one whose device is unplugged. The button turns red while the active config's device is away (a locked config waiting for it). "Manage device configs" opens Settings → Audio. Also shown in the full-screen player, beside the volume. - The player bar's EQ button can be hidden. On by default; Ctrl/⌘+E still opens the EQ. - Preferences.showOutputPicker (default off) and showEqButton (default on), so existing settings files keep today's player bar. - Config summary moved to deviceConfigSummary(), shared by Settings and the picker; the Audio section gets an #audio anchor. - Strings in all four languages. Co-Authored-By: Claude Opus 5.5 --- src-tauri/src/persistence/settings.rs | 18 ++- src/components/layout/PlayerBar.tsx | 11 +- src/components/player/OutputPicker.tsx | 141 ++++++++++++++++++ src/lib/deviceConfigs.test.ts | 33 ++++ src/lib/deviceConfigs.ts | 34 +++++ src/lib/i18n/messages/de.ts | 9 ++ src/lib/i18n/messages/en.ts | 8 + src/lib/i18n/messages/es.ts | 9 ++ src/lib/i18n/messages/fr.ts | 9 ++ src/lib/subsonic/types.ts | 4 + .../now-playing/NowPlayingOverlay.tsx | 2 + src/stores/prefsStore.ts | 2 + src/views/settings/SettingsView.tsx | 41 +++-- 13 files changed, 295 insertions(+), 26 deletions(-) create mode 100644 src/components/player/OutputPicker.tsx diff --git a/src-tauri/src/persistence/settings.rs b/src-tauri/src/persistence/settings.rs index cdba015..9521611 100644 --- a/src-tauri/src/persistence/settings.rs +++ b/src-tauri/src/persistence/settings.rs @@ -103,6 +103,12 @@ pub struct Preferences { /// when Reverb closed — or [`STARTUP_SYSTEM_DEFAULT`] for none. `None` — /// or an id no config has — starts on the one last active. pub startup_device_config: Option, + /// Show a device config picker in the player bar, beside the volume. Off + /// by default: switching is a Settings job until the listener asks. + pub show_output_picker: bool, + /// Show the button that opens the parametric EQ in the player bar. On by + /// default, as it was before it could be hidden. + pub show_eq_button: bool, /// "raw" for the original file, or "mp3-320" / "mp3-192" / "mp3-128" /// for server-side transcoding. pub streaming_format: String, @@ -185,6 +191,8 @@ impl Default for Preferences { device_configs: Vec::new(), active_device_config: None, startup_device_config: None, + show_output_picker: false, + show_eq_button: true, streaming_format: "raw".into(), replay_gain: ReplayGainSettings::default(), crossfade_secs: 0, @@ -426,7 +434,9 @@ mod tests { "seekBarThickness": "thick", "syncQueue": false, "checkForUpdates": false, - "discordPresence": true + "discordPresence": true, + "showOutputPicker": true, + "showEqButton": false }"#; let prefs: Preferences = serde_json::from_str(raw).expect("camelCase names must match"); assert!(prefs.direct_scrobble); @@ -439,6 +449,8 @@ mod tests { assert!(!prefs.sync_queue); assert!(!prefs.check_for_updates); assert!(prefs.discord_presence); + assert!(prefs.show_output_picker); + assert!(!prefs.show_eq_button); // ...and come back out under the same names. let back = serde_json::to_value(&prefs).unwrap(); @@ -452,6 +464,8 @@ mod tests { assert_eq!(back["syncQueue"], serde_json::json!(false)); assert_eq!(back["checkForUpdates"], serde_json::json!(false)); assert_eq!(back["discordPresence"], serde_json::json!(true)); + assert_eq!(back["showOutputPicker"], serde_json::json!(true)); + assert_eq!(back["showEqButton"], serde_json::json!(false)); } /// Before ListenBrainz, direct scrobbling was "Last.fm only". A settings @@ -790,6 +804,8 @@ mod tests { assert_eq!(s.prefs.output(), OutputSettings::default()); assert!(s.prefs.check_for_updates, "update checks default to on"); assert!(!s.prefs.discord_presence, "Discord presence defaults to off"); + assert!(!s.prefs.show_output_picker, "the player bar output picker defaults to off"); + assert!(s.prefs.show_eq_button, "the player bar EQ button stays shown"); // And the new shape round-trips. let back = serde_json::to_string(&s).unwrap(); let s2: Settings = serde_json::from_str(&back).unwrap(); diff --git a/src/components/layout/PlayerBar.tsx b/src/components/layout/PlayerBar.tsx index 34f54a5..2612012 100644 --- a/src/components/layout/PlayerBar.tsx +++ b/src/components/layout/PlayerBar.tsx @@ -9,6 +9,7 @@ import { ArtistLinks } from "../library/ArtistLinks"; import { CoverImage } from "../library/CoverImage"; import { StarButton } from "../library/StarButton"; import { IconButton } from "../ui/Button"; +import { OutputPicker } from "../player/OutputPicker"; import { SeekBar } from "../player/SeekBar"; import { SignalPathIndicator } from "../player/SignalPathIndicator"; import { TransportControls } from "../player/TransportControls"; @@ -41,6 +42,7 @@ export function PlayerBar() { const { setQueuePanelOpen, setNowPlayingOpen } = useUiStore.getState(); const queuePanelOpen = useUiStore((s) => s.queuePanelOpen); const liquid = usePrefsStore((s) => s.prefs.layout) === "liquid"; + const showEqButton = usePrefsStore((s) => s.prefs.showEqButton); const navigate = useNavigate(); const song = item?.song; @@ -94,9 +96,11 @@ export function PlayerBar() { {/* Right controls */}
- navigate(EQ_PATH)}> - - + {showEqButton && ( + navigate(EQ_PATH)}> + + + )} setQueuePanelOpen(!queuePanelOpen)} @@ -104,6 +108,7 @@ export function PlayerBar() { > +
diff --git a/src/components/player/OutputPicker.tsx b/src/components/player/OutputPicker.tsx new file mode 100644 index 0000000..7a564aa --- /dev/null +++ b/src/components/player/OutputPicker.tsx @@ -0,0 +1,141 @@ +// Output picker: switches the active device config from the player bar, so +// moving between, say, headphones and speakers needs no trip to Settings. Shown +// only when turned on in Settings → Audio, which is still where configs are +// made and edited. + +import { useQuery } from "@tanstack/react-query"; +import { DropdownMenu } from "radix-ui"; +import { Settings2, Speaker } from "lucide-react"; +import { useNavigate } from "react-router"; +import { activeDeviceConfig, AUDIO_PATH, deviceConfigSummary } from "../../lib/deviceConfigs"; +import { useT } from "../../lib/i18n"; +import { cmd } from "../../lib/ipc/commands"; +import { usePrefsStore } from "../../stores/prefsStore"; +import { useUiStore } from "../../stores/uiStore"; + +/** Radio value for the system default, which has no config id. */ +const SYSTEM_DEFAULT = ""; + +const itemClass = + "group flex cursor-pointer items-center gap-2.5 rounded px-2.5 py-1.5 text-sm outline-none select-none data-highlighted:bg-surface-2"; + +function Choice({ + value, + name, + summary, + missing = false, +}: { + value: string; + name: string; + summary: string; + /** The config's device is not plugged in. */ + missing?: boolean; +}) { + return ( + + + + + + + + {name} + + {summary} + + + + ); +} + +function Picker() { + const t = useT(); + const navigate = useNavigate(); + const prefs = usePrefsStore((s) => s.prefs); + const set = usePrefsStore((s) => s.set); + // Fetched with the button rather than on open, so the list reads right the + // moment it opens. The engine bridge refetches it when a device comes or goes. + const devices = useQuery({ queryKey: ["audio-devices"], queryFn: () => cmd("audio_list_devices") }); + const active = activeDeviceConfig(prefs); + + const activeName = active?.name ?? t("settings.systemDefault"); + // A config locked to its device stays active while the device is away, so + // the button says playback is waiting on it. + const activeMissing = active != null && deviceConfigSummary(active, devices.data, t).missing; + const label = t("signal.output", { device: activeName }); + const title = activeMissing ? `${label} · ${t("settings.deviceNotConnected")}` : label; + + function manage() { + // From the full-screen player too, which would otherwise cover Settings. + useUiStore.getState().setNowPlayingOpen(false); + navigate(AUDIO_PATH); + } + + return ( + + + + + + + + {t("player.outputHeading")} + + set({ activeDeviceConfig: id || null })} + > + + {prefs.deviceConfigs.map((config) => { + const { text, missing } = deviceConfigSummary(config, devices.data, t); + return ( + + ); + })} + + + + {t("player.manageDeviceConfigs")} + + + + + ); +} + +/** The player bar's device config picker, when Settings has it shown. */ +export function OutputPicker() { + const show = usePrefsStore((s) => s.prefs.showOutputPicker); + return show ? : null; +} diff --git a/src/lib/deviceConfigs.test.ts b/src/lib/deviceConfigs.test.ts index e2390b2..e683976 100644 --- a/src/lib/deviceConfigs.test.ts +++ b/src/lib/deviceConfigs.test.ts @@ -4,6 +4,7 @@ import { afterDeviceLost, canGoExclusive, deleteDeviceConfig, + deviceConfigSummary, deviceLabel, hqplayerAddress, isConnected, @@ -12,6 +13,7 @@ import { STARTUP_SYSTEM_DEFAULT, startupDeviceConfig, } from "./deviceConfigs"; +import { translator } from "./i18n/core"; import type { DeviceConfig, OutputDevice } from "./subsonic/types"; const desk: DeviceConfig = { @@ -149,6 +151,37 @@ describe("devices", () => { }); }); +describe("deviceConfigSummary", () => { + const t = translator("en"); + const fiioDesk: DeviceConfig = { ...desk, device: fiio.id, lockDevice: true }; + + it("names the device and how the config plays through it", () => { + expect(deviceConfigSummary(fiioDesk, [fiio], t)).toEqual({ + text: "FiiO BTR17 · Exclusive · Matches source rate · Locked", + missing: false, + }); + expect(deviceConfigSummary(speakers, [fiio], t)).toEqual({ + text: "System default · Shared", + missing: false, + }); + }); + + it("leads with an unplugged device", () => { + expect(deviceConfigSummary(fiioDesk, [mac], t)).toEqual({ + text: "Device not connected · Exclusive · Matches source rate · Locked", + missing: true, + }); + }); + + it("names the HQPlayer an HQPlayer config hands playback to", () => { + const hq = { ...desk, hqplayer: { host: "studio.local", port: 4321 } }; + expect(deviceConfigSummary(hq, [], t)).toEqual({ + text: "HQPlayer at studio.local", + missing: false, + }); + }); +}); + describe("canGoExclusive", () => { it("needs a direct device where devices are told apart that way (Linux)", () => { const linux: OutputDevice[] = [fiio]; diff --git a/src/lib/deviceConfigs.ts b/src/lib/deviceConfigs.ts index f83a14d..3c9438f 100644 --- a/src/lib/deviceConfigs.ts +++ b/src/lib/deviceConfigs.ts @@ -2,8 +2,13 @@ // These helpers return preference patches; the prefs store persists them, and // the backend reopens the output when the setup they describe changes. +import type { T } from "./i18n/core"; import type { DeviceConfig, HqPlayerEndpoint, OutputDevice, Preferences } from "./subsonic/types"; +/** Settings' audio section, where device configs are made and edited. */ +export const AUDIO_SECTION_ID = "audio"; +export const AUDIO_PATH = `/settings#${AUDIO_SECTION_ID}`; + /** * `startupDeviceConfig` value that starts every launch on the system default. * Config ids are nanoids or UUIDs, so none can be this. @@ -115,6 +120,35 @@ export function parsePort(text: string): number | null { return port >= 1 && port <= 65535 ? port : null; } +/** + * One line on what a config plays through and how: its device (or HQPlayer), + * shared or exclusive, and the options it turns on. `missing` when its device + * is not plugged in, in which case that is what the line leads with. + */ +export function deviceConfigSummary( + config: DeviceConfig, + devices: OutputDevice[] | undefined, + t: T, +): { text: string; missing: boolean } { + if (config.hqplayer) { + return { + text: t("settings.configHqplayer", { address: hqplayerAddress(config.hqplayer) }), + missing: false, + }; + } + const missing = !isConnected(devices, config.device); + const device = missing + ? t("settings.deviceNotConnected") + : (deviceLabel(devices, config.device) ?? t("settings.systemDefault")); + const parts = [ + device, + config.exclusiveOutput ? t("settings.configExclusive") : t("settings.configShared"), + ]; + if (config.matchSourceRate) parts.push(t("settings.configMatchRate")); + if (config.lockDevice) parts.push(t("settings.configLocked")); + return { text: parts.join(" · "), missing }; +} + /** Whether a config's device is plugged in. Unknown counts as yes. */ export function isConnected(devices: OutputDevice[] | undefined, device: string | null): boolean { return device == null || devices == null || findDevice(devices, device) != null; diff --git a/src/lib/i18n/messages/de.ts b/src/lib/i18n/messages/de.ts index fb0feae..5f5c7fe 100644 --- a/src/lib/i18n/messages/de.ts +++ b/src/lib/i18n/messages/de.ts @@ -59,6 +59,9 @@ export const de: Messages = { "player.mute": "Stumm schalten", "player.unmute": "Stummschaltung aufheben", "player.volume": "Lautstärke", + "player.outputHeading": "Ausgabe", + "player.outputSystemDefaultHint": "Geteilt, mit der eigenen Abtastrate des Geräts", + "player.manageDeviceConfigs": "Gerätekonfigurationen verwalten", "player.repeat": "Wiederholung: {mode}", "repeat.off": "aus", "repeat.all": "alle", @@ -470,6 +473,12 @@ export const de: Messages = { "settings.startupDeviceConfigHint": "Die Gerätekonfiguration, mit der Reverb startet, egal welche beim Beenden aktiv war. „Zuletzt verwendet“ macht dort weiter, wo du aufgehört hast.", "settings.startupDeviceConfigLastUsed": "Zuletzt verwendet", + "settings.outputPicker": "Ausgabewahl in der Player-Leiste", + "settings.outputPickerHint": + "Eine Schaltfläche neben der Lautstärke, die zwischen Gerätekonfigurationen wechselt, ohne die Einstellungen zu öffnen.", + "settings.eqButton": "Schaltfläche für den parametrischen EQ in der Player-Leiste", + "settings.eqButtonHint": + "Öffnet den EQ weiter unten. Strg+E (⌘E auf dem Mac) funktioniert in jedem Fall.", "settings.deviceConfigName": "Name", "settings.deviceConfigNameHint": "Leer lassen, um den Namen des Geräts zu verwenden.", "settings.systemDefaultConfigHint": diff --git a/src/lib/i18n/messages/en.ts b/src/lib/i18n/messages/en.ts index 22ad7aa..4dba3a5 100644 --- a/src/lib/i18n/messages/en.ts +++ b/src/lib/i18n/messages/en.ts @@ -72,6 +72,9 @@ export const en = { "player.mute": "Mute", "player.unmute": "Unmute", "player.volume": "Volume", + "player.outputHeading": "Output", + "player.outputSystemDefaultHint": "Shared, at the device's own rate", + "player.manageDeviceConfigs": "Manage device configs", "player.repeat": "Repeat: {mode}", "repeat.off": "off", "repeat.all": "all", @@ -495,6 +498,11 @@ export const en = { "settings.startupDeviceConfigHint": "Reverb starts on this config every time, whichever one was in use when it closed. “Last used” picks up where you left off.", "settings.startupDeviceConfigLastUsed": "Last used", + "settings.outputPicker": "Output picker in the player bar", + "settings.outputPickerHint": + "A button beside the volume that switches device configs without opening Settings.", + "settings.eqButton": "Parametric EQ button in the player bar", + "settings.eqButtonHint": "Opens the EQ below. Ctrl+E (⌘E on a Mac) works either way.", "settings.deviceConfigName": "Name", "settings.deviceConfigNameHint": "Leave empty to use the device's name.", "settings.systemDefaultConfigHint": diff --git a/src/lib/i18n/messages/es.ts b/src/lib/i18n/messages/es.ts index d250f1c..728b644 100644 --- a/src/lib/i18n/messages/es.ts +++ b/src/lib/i18n/messages/es.ts @@ -59,6 +59,9 @@ export const es: Messages = { "player.mute": "Silenciar", "player.unmute": "Activar sonido", "player.volume": "Volumen", + "player.outputHeading": "Salida", + "player.outputSystemDefaultHint": "Compartido, a la frecuencia propia del dispositivo", + "player.manageDeviceConfigs": "Gestionar configuraciones de dispositivo", "player.repeat": "Repetición: {mode}", "repeat.off": "desactivada", "repeat.all": "todo", @@ -470,6 +473,12 @@ export const es: Messages = { "settings.startupDeviceConfigHint": "La configuración de dispositivo con la que arranca Reverb, sea cual sea la que estaba en uso al cerrarlo. “Última usada” continúa donde lo dejaste.", "settings.startupDeviceConfigLastUsed": "Última usada", + "settings.outputPicker": "Selector de salida en la barra de reproducción", + "settings.outputPickerHint": + "Un botón junto al volumen para cambiar de configuración de dispositivo sin abrir Ajustes.", + "settings.eqButton": "Botón del ecualizador paramétrico en la barra de reproducción", + "settings.eqButtonHint": + "Abre el ecualizador más abajo. Ctrl+E (⌘E en Mac) funciona en cualquier caso.", "settings.deviceConfigName": "Nombre", "settings.deviceConfigNameHint": "Déjalo vacío para usar el nombre del dispositivo.", "settings.systemDefaultConfigHint": diff --git a/src/lib/i18n/messages/fr.ts b/src/lib/i18n/messages/fr.ts index 0b41880..a5a773f 100644 --- a/src/lib/i18n/messages/fr.ts +++ b/src/lib/i18n/messages/fr.ts @@ -59,6 +59,9 @@ export const fr: Messages = { "player.mute": "Couper le son", "player.unmute": "Rétablir le son", "player.volume": "Volume", + "player.outputHeading": "Sortie", + "player.outputSystemDefaultHint": "Partagé, à la fréquence propre du périphérique", + "player.manageDeviceConfigs": "Gérer les configurations de périphérique", "player.repeat": "Répétition : {mode}", "repeat.off": "désactivée", "repeat.all": "tout", @@ -471,6 +474,12 @@ export const fr: Messages = { "settings.startupDeviceConfigHint": "La configuration de périphérique avec laquelle Reverb démarre, quelle que soit celle utilisée à sa fermeture. « Dernière utilisée » reprend là où vous vous étiez arrêté.", "settings.startupDeviceConfigLastUsed": "Dernière utilisée", + "settings.outputPicker": "Sélecteur de sortie dans la barre de lecture", + "settings.outputPickerHint": + "Un bouton à côté du volume pour changer de configuration de périphérique sans ouvrir les réglages.", + "settings.eqButton": "Bouton de l'égaliseur paramétrique dans la barre de lecture", + "settings.eqButtonHint": + "Ouvre l'égaliseur plus bas. Ctrl+E (⌘E sur Mac) fonctionne dans tous les cas.", "settings.deviceConfigName": "Nom", "settings.deviceConfigNameHint": "Laissez vide pour utiliser le nom du périphérique.", "settings.systemDefaultConfigHint": diff --git a/src/lib/subsonic/types.ts b/src/lib/subsonic/types.ts index 2624334..9522a81 100644 --- a/src/lib/subsonic/types.ts +++ b/src/lib/subsonic/types.ts @@ -433,6 +433,10 @@ export interface Preferences { * launch, before the engine opens. */ startupDeviceConfig: string | null; + /** Show a device config picker in the player bar, beside the volume. */ + showOutputPicker: boolean; + /** Show the button that opens the parametric EQ in the player bar. */ + showEqButton: boolean; streamingFormat: StreamingFormat; replayGain: ReplayGainSettings; /** Crossfade between tracks in seconds (0 = gapless). */ diff --git a/src/overlays/now-playing/NowPlayingOverlay.tsx b/src/overlays/now-playing/NowPlayingOverlay.tsx index 77927b3..3ce9336 100644 --- a/src/overlays/now-playing/NowPlayingOverlay.tsx +++ b/src/overlays/now-playing/NowPlayingOverlay.tsx @@ -15,6 +15,7 @@ import { CoverImage } from "../../components/library/CoverImage"; import { EntityGenreBubbles } from "../../components/library/GenreBubbles"; import { StarButton } from "../../components/library/StarButton"; import { IconButton } from "../../components/ui/Button"; +import { OutputPicker } from "../../components/player/OutputPicker"; import { SeekBar } from "../../components/player/SeekBar"; import { SignalPathIndicator } from "../../components/player/SignalPathIndicator"; import { TransportControls } from "../../components/player/TransportControls"; @@ -235,6 +236,7 @@ export function NowPlayingOverlay() {
+
diff --git a/src/stores/prefsStore.ts b/src/stores/prefsStore.ts index 2bb143c..7c3dafd 100644 --- a/src/stores/prefsStore.ts +++ b/src/stores/prefsStore.ts @@ -147,6 +147,8 @@ const DEFAULT_PREFS: Preferences = { deviceConfigs: [], activeDeviceConfig: null, startupDeviceConfig: null, + showOutputPicker: false, + showEqButton: true, streamingFormat: "raw", replayGain: { mode: "off", preampDb: 0, clipProtection: true, fallbackDb: 0 }, crossfadeSecs: 0, diff --git a/src/views/settings/SettingsView.tsx b/src/views/settings/SettingsView.tsx index ef61a3e..9ce3f0c 100644 --- a/src/views/settings/SettingsView.tsx +++ b/src/views/settings/SettingsView.tsx @@ -38,8 +38,10 @@ import { MultiSelect } from "../../components/ui/MultiSelect"; import { ConfirmDialog } from "../../components/ui/Dialogs"; import { activeDeviceConfig, + AUDIO_SECTION_ID, canGoExclusive, deleteDeviceConfig, + deviceConfigSummary, deviceLabel, HQPLAYER_DEFAULT_PORT, hqplayerAddress, @@ -409,26 +411,6 @@ function AudioSection() { const [editing, setEditing] = useState<{ config: DeviceConfig; isNew: boolean } | null>(null); const [deleting, setDeleting] = useState(null); - function summary(config: DeviceConfig): { text: string; missing: boolean } { - if (config.hqplayer) { - return { - text: t("settings.configHqplayer", { address: hqplayerAddress(config.hqplayer) }), - missing: false, - }; - } - const missing = !isConnected(deviceList, config.device); - const device = missing - ? t("settings.deviceNotConnected") - : (deviceLabel(deviceList, config.device) ?? t("settings.systemDefault")); - const parts = [ - device, - config.exclusiveOutput ? t("settings.configExclusive") : t("settings.configShared"), - ]; - if (config.matchSourceRate) parts.push(t("settings.configMatchRate")); - if (config.lockDevice) parts.push(t("settings.configLocked")); - return { text: parts.join(" · "), missing }; - } - return (
@@ -465,7 +447,7 @@ function AudioSection() { onSelect={() => set({ activeDeviceConfig: null })} /> {prefs.deviceConfigs.map((config) => { - const { text, missing } = summary(config); + const { text, missing } = deviceConfigSummary(config, deviceList, t); return ( )} + + set({ showOutputPicker })} + /> + + + set({ showEqButton })} + /> + + {/* Reverb's own stream; with HQPlayer playing there is none, and the signal path shows HQPlayer's rate instead. */} {!active?.hqplayer && ( @@ -2083,7 +2078,9 @@ export function SettingsView() { - +
+ +