Skip to main content
Version: 5.5

Mute sharing and control

Mute refers to disabling the transmission of audio captured by the microphone. You can mute or unmute local audio and share your application's mute status with peers. You can also request a specific peer or all peers to mute or unmute their audio.

Control and share local audio mute

To mute or unmute local audio, use muteMyAudio().

1-to-1 call

In 1-to-1 calls, the status change of local audio mute is sent to peers through evtPeerMicMuted or evtPeerMicUnmuted.

1-to-1 call mute local audio sequence diagram

Related sample code is as follows.

Muting or unmuting local audio

const planetKit = new PlanetKit.Call();

const isMute = true; // true for mute, false for unmute

planetKit.muteMyAudio(isMute)
.then(() => {
console.log(`muteMyAudio(isMute=${isMute})`);
})
.catch((error) => {
console.error(`muteMyAudio(isMute=${isMute}) failed:`, error);
});
const onEvtPeerMicMuted = () => {
// This is called when the peer changed their microphone status to be muted.
// Write your own code here.
};

const onEvtPeerMicUnmuted = () => {
// This is called when the peer changed their microphone status to be unmuted.
// Write your own code here.
};

// MakeCallParams for caller, VerifyCallParams for callee
const makeCallParams = {
...
delegate: {
...
evtPeerMicMuted: onEvtPeerMicMuted,
evtPeerMicUnmuted: onEvtPeerMicUnmuted
}
};

// Set the parameter when making or verifying a call

Group call

In group calls, the status change of local audio mute is sent to peers through evtPeersMicMuted or evtPeersMicUnmuted.

Group call mute local audio sequence diagram

Related sample code is as follows.

Muting or unmuting local audio

const planetKit = new PlanetKit.Conference();

const isMute = true; // true for mute, false for unmute

planetKit.muteMyAudio(isMute)
.then(() => {
console.log(`muteMyAudio(isMute=${isMute})`);
})
.catch((error) => {
console.error(`muteMyAudio(isMute=${isMute}) failed:`, error);
});
const onEvtPeersMicMuted = (peersMicMutedParam) => {
// This is called when one or more peers changed their microphone status to be muted.
// Write your own code here.
};

const onEvtPeersMicUnmuted = (peersMicUnmutedParam) => {
// This is called when one or more peers changed their microphone status to be unmuted.
// Write your own code here.
};

const conferenceParams = {
...
delegate: {
...
evtPeersMicMuted: onEvtPeersMicMuted,
evtPeersMicUnmuted: onEvtPeersMicUnmuted
}
};

// Set the parameter when joining a conference

Request remote audio mute

You can request a specific peer or all peers to mute or unmute their audio.

  • To request a specific peer to mute or unmute one's own audio in 1-to-1 calls or group calls, use requestPeerMute().
  • To request all peers to mute or unmute their audio in group calls, use requestPeersMute().

Requests for mute are notified to peers through evtMyMuteRequestedByPeer.

Note

Whether the peers need to mute or unmute their audio when they get a request is implementation-dependent.

The following examples assume that the peers will mute or unmute their audio according to the request.

1-to-1 call

In 1-to-1 calls, the status change of remote audio mute is sent to the local user through evtPeerMicMuted or evtPeerMicUnmuted.

1-to-1 call mute remote audio sequence diagram

Related sample code is as follows.

Requesting to mute or unmute remote audio

const planetKit = new PlanetKit.Call();

const isMute = true; // true for mute, false for unmute

planetKit.requestPeerMute(isMute);
const onEvtMyMuteRequestedByPeer = (isMute) => {
// This is called when the peer requests the local user to mute or unmute the microphone.
planetKit.muteMyAudio(isMute)
.then(() => {
console.log(`muteMyAudio(isMute=${isMute})`);
})
.catch((error) => {
console.error(`muteMyAudio(isMute=${isMute}) failed:`, error);
});
};

// MakeCallParams for caller, VerifyCallParams for callee
const makeCallParams = {
...
delegate: {
...
evtMyMuteRequestedByPeer: onEvtMyMuteRequestedByPeer
}
};

// Set the parameter when making or verifying a call

Group call

In group calls, the status change of remote audio mute is sent to the local user through evtPeersMicMuted or evtPeersMicUnmuted.

Group call mute remote audio sequence diagram

Related sample code is as follows.

Requesting to mute or unmute remote audio

const planetKit = new PlanetKit.Conference();

const userId = 'target-user-id'; // peer user ID
const isMute = true; // true for mute, false for unmute

// Request mute for single peer
planetKit.requestPeerMute(userId, isMute);

// Request mute for all peers
planetKit.requestPeersMute(isMute);
const onEvtMyMuteRequestedByPeer(peer, isMute) => {
// This is called when the peer requests the local user to mute or unmute the microphone.
planetKit.muteMyAudio(isMute)
.then(() => {
console.log(`muteMyAudio(isMute=${isMute})`);
})
.catch((error) => {
console.error(`muteMyAudio(isMute=${isMute}) failed:`, error);
});
};

const conferenceParams = {
...
delegate: {
...
evtMyMuteRequestedByPeer: onEvtMyMuteRequestedByPeer
}
};

// Set the parameter when joining a conference

APIs related to mute sharing and control are as follows.

1-to-1 call

Methods

Events

Group call

Methods

Events