Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/components/Group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default function Group(props: GroupProps) {
const [settingsOpen, setSettingsOpen] = useState(false);
const [clients, setClients] = useState<GroupClient[]>([]);
const [streamId, setStreamId] = useState("");
const [groupName, setGroupName] = useState("");
const [deletedClients, setDeletedClients] = useState<Snapcast.Client[]>([]);
const [volume, setVolume] = useState(0);
const groupVolumeChange = useRef<GroupVolumeChange>({ volumeEntered: true, client_volumes: new Map<string, number>(), group_volume: 0 });
Expand Down Expand Up @@ -66,6 +67,7 @@ export default function Group(props: GroupProps) {
setSettingsOpen(true);
setClients(clients);
setStreamId(props.group.stream_id)
setGroupName(props.group.name);
}

function handleSettingsClose(apply: boolean) {
Expand All @@ -89,6 +91,9 @@ export default function Group(props: GroupProps) {

if (props.group.stream_id !== streamId)
props.snapcontrol.setStream(props.group.id, streamId);

if(props.group.name !== groupName)
props.snapcontrol.setGroupName(props.group.id, groupName);
}
setSettingsOpen(false);
}
Expand Down Expand Up @@ -252,7 +257,7 @@ export default function Group(props: GroupProps) {
justifyContent="space-between"
alignItems="center"
>
<Stack direction="row" justifyContent="center" alignItems="center" >
<Stack direction="row" justifyContent="center" alignItems="center" gap="1rem">
<IconButton aria-label="Options" onClick={(event) => { handleSettingsClicked(event); }}>
<SettingsIcon />
</IconButton>
Expand All @@ -272,6 +277,10 @@ export default function Group(props: GroupProps) {
{props.server.streams.map(stream => <MenuItem key={stream.id} value={stream.id}>{stream.id}</MenuItem>)}
</Select>
</FormControl>

<Typography noWrap variant="subtitle1">
{props.group.name}
</Typography>
</Stack>

{stream?.properties.canControl &&
Expand Down Expand Up @@ -330,6 +339,12 @@ export default function Group(props: GroupProps) {
<Dialog fullWidth open={settingsOpen} onClose={() => { handleSettingsClose(false) }}>
<DialogTitle>Group settings</DialogTitle>
<DialogContent>
<Divider textAlign="left">Name</Divider>
<TextField
margin="dense" id="group-name" fullWidth variant="standard"
value={groupName}
onChange={(event) => setGroupName(event.target.value) }
/>
<Divider textAlign="left">Stream</Divider>
<TextField
// label="Stream"
Expand Down
7 changes: 7 additions & 0 deletions src/snapcontrol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ class SnapControl {
stream = this.getStream(notification.params.id);
stream.properties.fromJson(notification.params.properties);
return true;
case 'Group.OnNameChanged':
this.getGroup(notification.params.id).name = notification.params.name;
return true;
default:
return false;
}
Expand Down Expand Up @@ -388,6 +391,10 @@ class SnapControl {
return this.getStream(group.stream_id);
}

public setGroupName(group_id: string, name: string) {
this.sendRequest('Group.SetName', { id: group_id, name: name });
}

// public getMyStreamId(): string {
// try {
// let group: Group = this.getGroupFromClient(SnapStream.getClientId());
Expand Down