Remote Mute
You're running a room and decide that someone who's currently talking shouldn't be talking.
You'd prefer they'd stay mute. Or perhaps you want their video turned off as well as their audio. You're looking for a remote mute.
Muting can apply to both audio and video.
Unmuting
You may also decide that you want to let someone else speak who was currently muted. Or may want to ask someone to turn on their video.
You can request people to unmute themselves as well.
Permissions
Can't let just anyone mute others. First you need to create a role with the permissions to end a room.
The permission to end a room is called mute
and you should check for that within the permissions
property of HMSRole
of the peer to see if they have it.
Muting/Unmuting
Once you have checked that the caller has permissions to mute another peer's audio or video, call for it with hmsSdk.changeTrackState
.
To mute a track:
Get the audio or video track of the peer whom you want to mute and pass it as the first parameter to hmsSdk.changeTrackState
.
The second parameter is a boolean for muting. If true, the track will be muted. If false the track will be requested to unmute.
Finally you can pass a completion handler to check whether changeTrackState suceeded or failed as the third parameter.
Handling a mute callback
Muting is automatically applied to the receiver tracks. No action is required.
Handling an unmute callback
Unmute callbacks are received in the target peer's on(changeTrackStateRequest:)
callback of HMSUpdateListener
.
The target peer will receive an object of HMSChangeTrackStateRequest
.
Here's its structure.
class HMSChangeTrackStateRequest { public let track: HMSTrack public let mute: Bool public let requestedBy: HMSPeer }
With the information here, show a dialog to the user to ask if they want to accept the change and then apply the settings locally. The same as in a regular user Mute/Unmute.