feat(webrtc): add admin option to mute other participants
This commit is contained in:
@@ -99,6 +99,33 @@ func (c *Client) ListParticipants(roomName string) ([]*livekit.ParticipantInfo,
|
||||
return resp.Participants, nil
|
||||
}
|
||||
|
||||
func (c *Client) MuteParticipant(roomName string, identity string) error {
|
||||
if c == nil {
|
||||
return fmt.Errorf("voice client not configured")
|
||||
}
|
||||
|
||||
participant, err := c.roomClient.GetParticipant(context.Background(), &livekit.RoomParticipantIdentity{
|
||||
Room: roomName,
|
||||
Identity: identity,
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("get participant: %w", err)
|
||||
}
|
||||
|
||||
for _, track := range participant.Tracks {
|
||||
_, err := c.roomClient.MutePublishedTrack(context.Background(), &livekit.MuteRoomTrackRequest{
|
||||
Room: roomName,
|
||||
Identity: identity,
|
||||
TrackSid: track.Sid,
|
||||
Muted: true,
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("mute track %s: %w", track.Sid, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func boolPtr(b bool) *bool {
|
||||
return &b
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user