From deacb74d3985fd65ac53976b8527e87efda1f653 Mon Sep 17 00:00:00 2001 From: Fredrik Lanker Date: Sat, 10 May 2025 15:34:21 +0200 Subject: [PATCH 1/2] Add setting for max volume per client --- src/components/Client.tsx | 12 ++++++++++-- src/snapcontrol.ts | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/components/Client.tsx b/src/components/Client.tsx index b23dd76..e76f050 100644 --- a/src/components/Client.tsx +++ b/src/components/Client.tsx @@ -4,6 +4,7 @@ import { SnapControl, Snapcast } from '../snapcontrol'; import { Box, Button, Grid, InputAdornment, Menu, MenuItem, Slider, Stack, TextField, Typography, IconButton } from '@mui/material'; import { Dialog, DialogActions, DialogContent, DialogTitle } from '@mui/material'; import { VolumeUp as VolumeUpIcon, VolumeOff as VolumeOffIcon, MoreVert as MoreVertIcon } from '@mui/icons-material'; +import { getPersistentValue, setPersistentValue } from '../config'; type ClientProps = { @@ -22,11 +23,13 @@ export default function Client(props: ClientProps) { const [name, setName] = useState(props.client.config.name); const [tmpLatency, setTmpLatency] = useState(props.client.config.latency); const [latency, setLatency] = useState(props.client.config.latency); + const persistantMaxVolumeKey = `${props.client.id}-maxVolume`; + const [maxVolume, setMaxVolume] = useState(Number(getPersistentValue(persistantMaxVolumeKey, "100") ?? 100)); function handleVolumeChange(value: number) { console.debug("handleVolumeChange: " + value); props.client.config.volume.percent = value; - props.snapcontrol.setVolume(props.client.id, value, false); + props.snapcontrol.setVolume(props.client.id, value, maxVolume, false); // setState({}); props.onVolumeChange(); } @@ -105,7 +108,7 @@ export default function Client(props: ClientProps) { { handleMuteClicked() }}> {props.client.config.volume.muted ? : } - { handleVolumeChange(value as number) }} /> + { handleVolumeChange(value as number) }} /> @@ -147,6 +150,11 @@ export default function Client(props: ClientProps) { } }} /> + ) => { setPersistentValue(persistantMaxVolumeKey, event.target.value); setMaxVolume(Number(event.target.value)) }} + value={maxVolume} + /> Date: Sat, 10 May 2025 15:37:45 +0200 Subject: [PATCH 2/2] Show labels for volume sliders --- src/components/Client.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Client.tsx b/src/components/Client.tsx index e76f050..c19ea08 100644 --- a/src/components/Client.tsx +++ b/src/components/Client.tsx @@ -108,7 +108,7 @@ export default function Client(props: ClientProps) { { handleMuteClicked() }}> {props.client.config.volume.muted ? : } - { handleVolumeChange(value as number) }} /> + { handleVolumeChange(value as number) }} />