Mute & Unmute
Mute is something that applies to both audio and video. When you mute audio, you can't be heard by other people i.e your audio is OFF. When you mute a video, you will not be broadcasting your video to other people i.e your video is OFF.
Check Mute Status
Current Mute Status of any
HMSTrack can be checked by calling
isMute method on it.
In most of the cases, You would need current mute status to toggle mute and render correct mic and camera icons.
// You can get `HMSTrack` object from `HMSPeer` object // or `HMSUpdateListenerActions.ON_TRACK_UPDATE` event const audioMuted = peer.audioTrack?.isMute(); // audioTrack property can be undefined const videoMuted = peer.videoTrack?.isMute(); // videoTrack property can be undefined
Change Your(Local Peer) Mute Status
To switch your "video" or "audio" on/off, you can call
setMute method available on
HMSLocalAudioTrack objects respectively with
If you want to toggle mute status of your "video" or "audio", then you can first get the current mute status and then pass opposite value to
// instance acquired from build() method const localPeer = await hmsInstance.getLocalPeer(); // Muting Example - localPeer.localAudioTrack().setMute(true); // Muting Local Audio localPeer.localVideoTrack().setMute(true); // Muting Local Video // Toggling Mute Example - const audioMuted = localPeer.audioTrack?.isMute(); // Toggling Local Audio, audio will be unmuted localPeer.localAudioTrack().setMute(!audioMuted); // passing opposite value of audioMuted const videoMuted = localPeer.videoTrack?.isMute(); // Toggling Local Video, video will be unmuted localPeer.localVideoTrack().setMute(!videoMuted); // passing opposite value of videoMuted