Mute / Unmute Mic - React
Muting and Unmuting your microphone refers to turning your microphone off and on, respectively.
Muting your microphone prevents the transmission of any sound from your microphone to other meeting participants, while unmuting allows them to hear you.
unmuteMic()
- 
By using the unmuteMic()function of theuseMeetinghook, the local participant can publish their audio to other participants.- You can only call this method when the local participant is not broadcasting audio to others.
 
- 
You can also pass a customised audio track in the unmuteMic()method by using Custom Audio Track.
- 
Audio stream of the participant can be accessed from the micStreamproperty of theuseParticipanthook.
muteMic()
- 
By using the muteMic()function of theuseMeetinghook, the local participant can stop publishing their audio to other participants.
- 
You can only call this method when the local participant is broadcasting audio to others. 
toggleMic()
- 
By utilizing the toggleMic()function ofuseMeetinghook, the local participant can start or stop publishing their audio to other participants based on the current state of the mic.
- 
You can also pass a customised audio track in the toggleMic()method by using Custom Audio Track.
- 
The audio stream of a participant can be accessed from the micStreamproperty of theuseParticipanthook.
Example
import { useMeeting } from "@videosdk.live/react-sdk";
const MeetingView = () => {
  //Getting the mic methods from hook
  const { unmuteMic, muteMic, toggleMic } = useMeeting();
  const handleUnmuteMic = () => {
    // Unmuting Mic
    unmuteMic();
  };
  const handleMuteMic = () => {
    // Muting Mic
    muteMic();
  };
  const handleToggleMic = () => {
    // Toggling Mic
    toggleMic();
  };
  return (
    <>
      <button onClick={handleMuteMic}>Mute Mic</button>
      <button onClick={handleUnmuteMic}>Unmute Mic</button>
      <button onClick={handleToggleMic}>Toggle Mic</button>
    </>
  );
};
To learn, how to render audio in the meeting, follow this detailed guide.
Events associated with unmuteMic
- 
Every Participant will receive a callback on onStreamEnabled()event of theuseParticipant()hook with theStreamobject.
- 
Every Participant will receive a callback on onMediaStatusChanged()event of theuseParticipant()hook with the type of media and its status.
Events associated with muteMic
- 
Every Participant will receive a callback on onStreamDisabled()event of theuseParticipant()hook with theStreamobject.
- 
Every Participant will receive a callback on onMediaStatusChanged()event of theuseParticipant()hook with the type of media and its status.
Events associated with toggleMic
- 
Every Participant will receive a callback on onStreamEnabled()event of theuseParticipant()hook with theStreamobject if the audio broadcasting was started.
- 
Every Participant will receive a callback on onStreamDisabled()event of theuseParticipant()hook with theStreamobject if the audio broadcasting was stopped.
- 
Every Participant will receive a callback on onMediaStatusChanged()event of theuseParticipant()hook with the type of media and its status.
import { useParticipant } from "@videosdk.live/react-sdk";
const ParticipantView = (participantId) => {
  //Callback for when the participant starts a stream
  function onStreamEnabled(stream) {
    if(stream.kind === 'audio'){
      console.log("Audio Stream On: onStreamEnabled", stream);
    }
  }
  //Callback for when the participant stops a stream
  function onStreamDisabled(stream) {
    if(stream.kind === 'audio'){
      console.log("Audio Stream Off: onStreamDisabled", stream);
    }
  }
  //Callback for when participant's media changes
  function onMediaStatusChanged(data) {
    const { kind, newStatus} = data;
    console.log("Participant Media Kind: ", kind, " newStatus: ", newStatus);
  }
  const {
    displayName
    ...
  } = useParticipant(participantId,{
    onStreamEnabled,
    onStreamDisabled,
    onMediaStatusChanged
    ...
  });
  return <> Participant View </>;
}
Getting Participant's Mic Status
- You can get the local participant's mic status from the useMeetinghook using a property calledlocalMicOn.
- If localMicOnistrue, it means that the local participant's microphone is currently active. If it isfalse, it means that the local participant's microphone is currently muted or inactive.
import { useMeeting } from "@videosdk.live/react-sdk";
const MeetingView = () => {
  // Get the localMicOn property
  const { localMicOn } = useMeeting();
  return <> Local Mic is {localMicOn} </>;
};
- To get the status of any other participant's media you can use the micOnproperty of theuseParticipanthook. This parameter will betrueif the participant'smic is onotherwise, it will befalse.
import { useParticipant } from "@videosdk.live/react-sdk";
const ParticipantView = (participantId) => {
  // Get the micOn property
  const { micOn } = useParticipant(participantId);
  return <> Participant Mic is {micOn} </>;
};
Audio Permissions
- By default, VideoSDK will request audio permission when a participant attempts to turn on the mic. Once the permission is granted, the mic is activated. If the permission is denied, VideoSDK will send an error message in the onErrorevent callback of theuseMeetinghook.
Troubleshoot Audio Permissions
- If a participant denies the microphone permission, they can manually grant it by following the below shown steps.
To use the audio and video communications in the web browser, your site must be SSL enabled, i.e. it must be secured and running on https.
API Reference
The API references for all the methods and events utilized in this guide are provided below.
Got a Question? Ask us on discord

