Remote Mute/Unmute

You're running a room and decide that someone who's currently talking shouldn't be talking or perhaps you want their video turned off as well. You're looking for a remote mute/unmute in this case.

Muting/Unmuting

Use the selectPermissions selector to check whether the local peer has the permission to mute or unmute others and then call hmsActions.setRemoteTrackEnabled with the trackID of the track you want to mute/unmute and enable(true for unmuting, false for muting).

try { await hmsActions.setRemoteTrackEnabled(peer.audioTrack, true); } catch (error) { // Permission denied or invalid track ID or not connected to room console.error(error); }

🚧 If the local peer doesn't have the required mute/unmute permission, the hmsActions.setRemoteTrackEnabled call will throw an HMSException error.

Handling a mute/unmute request

Once the peer with adequate permissions calls setRemoteTrackEnabled, the local peer will receive a notification with type CHANGE_TRACK_STATE_REQUEST with a HMSChangeTrackStateRequest object as the data.

  • Mute requests are automatically applied to the receiver by the SDK. No action is required.

  • For unmute request, hold onto the information from the HMSChangeTrackStateRequest object, 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.

hmsNotifications.onNotification((notification) => { if (!notification) { return; } switch (notification.type) { // ...Other notification type cases case 'CHANGE_TRACK_STATE_REQUEST': // Unmute Request if (notification.data.enabled) { // Ask for consent using dialog or any other appropriate UI await hmsActions.setEnabledTrack(notification.data.track.id, enabled); } else { // Mute Request // Show toast to user } break; } });

Remote Unmute Request