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.
Prior to PlanetKit 6.0, muting did not directly affect the operation of microphone. Starting with PlanetKit 6.0, however, the microphone is controlled by muting as follows:
- When you mute the local audio, PlanetKit turns off the microphone and disables audio transmission, making the microphone indicator turned off.
- When you unmute the local audio, PlanetKit turns on the microphone and enables audio transmission, making the microphone indicator turned on.
Control and share local audio mute
This section explains how to mute or unmute local audio by call type.
1-to-1 call
To mute or unmute local audio in 1-to-1 calls, use muteMyAudio(). The changes in the mute status of local audio are sent to peers through onPeerMicMuted or onPeerMicUnmuted.
The following diagram shows the flow of muting and unmuting local audio in a 1-to-1 call.
Related sample code is as follows.
Muting or unmuting local audio
// isMute: true for mute, false for unmute
fun muteMyAudioExample(call: PlanetKitCall, isMute: Boolean) {
call.muteMyAudio(isMute) { result ->
Log.d(TAG, "muteMyAudio(isMute=$isMute) result: ${result.isSuccessful}")
}
}
Handling related events on the peer side
// Implement related callbacks of the CallListener interface
// MakeCallListener for caller and AcceptCallListener for callee
private val makeAcceptCallListener = object : MakeCallListener, AcceptCallListener {
...
override fun onPeerMicMuted(call: PlanetKitCall) {
// This is called when the peer changed their microphone status to be muted.
// Write your own code here.
}
override fun onPeerMicUnmuted(call: PlanetKitCall) {
// This is called when the peer changed their microphone status to be unmuted.
// Write your own code here.
}
}
Group call
To mute or unmute local audio in group calls, use muteMyAudio(). The changes in the mute status of local audio are sent to peers through onPeersMicMuted or onPeersMicUnmuted.
The following diagram shows the flow of muting and unmuting local audio in a group call.
Related sample code is as follows.
Muting or unmuting local audio
// isMute: true for mute, false for unmute
fun muteMyAudioExample(conference: PlanetKitConference, isMute: Boolean) {
conference.muteMyAudio(isMute) { result ->
Log.d(TAG, "muteMyAudio(isMute=$isMute) result: ${result.isSuccessful}")
}
}
Handling related events on the peer side
// Implement related callbacks of the ConferenceListener interface
private val conferenceListener = object : ConferenceListener {
...
override fun onPeersMicMuted(conference: PlanetKitConference, peers: List<PlanetKitConferencePeer>) {
// This is called when one or more peers changed their microphone status to be muted.
// Write your own code here.
}
override fun onPeersMicUnmuted(conference: PlanetKitConference, peers: List<PlanetKitConferencePeer>) {
// This is called when one or more peers changed their microphone status to be unmuted.
// Write your own code here.
}
}
Request remote audio mute
This section explains how to request muting or unmuting of remote audio by call type.
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
To request a peer to mute or unmute in 1-to-1 calls, use requestPeerMute(). This request is sent to the peer through onMuteMyAudioRequestedByPeer, and changes in the mute status of remote audio are sent to the local user through onPeerMicMuted or onPeerMicUnmuted.
The following diagram shows the flow of requesting to mute and unmute remote audio in a 1-to-1 call.
Related sample code is as follows.
Requesting to mute or unmute remote audio
// isMute: true for mute, false for unmute
fun requestPeerMuteExample(call: PlanetKitCall, isMute: Boolean) {
call.requestPeerMute(isMute) { result ->
Log.d(TAG, "requestPeerMute(isMute=$isMute) result: ${result.isSuccessful}")
}
}
Handling related events on the peer side
private val makeAcceptCallListener = object : MakeCallListener, AcceptCallListener {
...
override fun onMuteMyAudioRequestedByPeer(call: PlanetKitCall, isMute: Boolean) {
// This is called when the peer requests the local user to mute or unmute the microphone.
call.muteMyAudio(isMute) { result ->
Log.d(TAG, "muteMyAudio(isMute=$isMute) result: ${result.isSuccessful}")
}
}
}
Group call
In group calls, 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, use
requestPeerMute(). - To request all peers to mute or unmute their audio, use
requestPeersMute().
These requests are sent to peers through onMuteMyAudioRequestedByPeer and the changes in the mute status of remote audio are sent to the local user through onPeersMicMuted or onPeersMicUnmuted.
The following diagram shows the flow of requesting to mute and unmute remote audio in a group call.
Related sample code is as follows.
Requesting to mute or unmute remote audio
// Request mute for single peer
// isMute: true for mute, false for unmute
fun requestPeerMuteExample(conference: PlanetKitConference, peer: PlanetKitUser, isMute: Boolean) {
conference.requestPeerMute(peer, isMute) { result ->
Log.d(TAG, "requestPeerMute(peer=$peer, isMute=$isMute) result: ${result.isSuccessful}")
}
}
// Request mute for all peers
// isMute: true for mute, false for unmute
fun requestPeersMuteExample(conference: PlanetKitConference, isMute: Boolean) {
conference.requestPeersMute(isMute) { result ->
Log.d(TAG, "requestPeersMute(isMute=$isMute) result: ${result.isSuccessful}")
}
}
Handling related events on the peer side
private val conferenceListener = object : ConferenceListener {
...
override fun onMuteMyAudioRequestedByPeer(conference: PlanetKitConference, peer: PlanetKitConferencePeer, isMute: Boolean) {
// This is called when a peer requests the local user to mute or unmute the microphone.
conference.muteMyAudio(isMute) { result ->
Log.d(TAG, "muteMyAudio(isMute=$isMute) result: ${result.isSuccessful}")
}
}
}
Related API
APIs related to mute sharing and control are as follows.
1-to-1 call
Methods
Events
-
onPeerMicMutedofCallListener -
onPeerMicUnmutedofCallListener -
onMuteMyAudioRequestedByPeerofCallListener
Group call
Methods
-
muteMyAudio()ofPlanetKitConference -
requestPeerMute()ofPlanetKitConference -
requestPeersMute()ofPlanetKitConference