Skip to content

Media controls ​

These APIs let you control local and remote audio behavior during an active call.

Client-side vs server-side controls

Mute and audio processing (noise suppression, auto gain control, echo cancellation) are applied locally on the device — they stop audio from being sent or filter it before transmission. Earmuff is applied server-side — the Vonage API suppresses the incoming audio stream before it reaches the client.

Platform availability ​

ControlAndroidiOSWeb
Mute / UnmuteYesYesYes
EarmuffYesYesYes
DTMFYesYesYes
Noise suppressionYesYesYes
Auto gain controlNoNoYes
Echo cancellationNoNoYes

Android and iOS apply noise suppression with Vonage's on-device machine-learning model. Web uses the browser's built-in WebRTC audio processing, which is also what makes auto gain control and echo cancellation available there and not on mobile.

Mute ​

Mute the local microphone so the remote party cannot hear you. The call remains active.


// Callback
client.mute("callId") {
    it?.let { err ->
        // Handle Error in muting call
        println("Error in muting call: $err")
    }
}

// Coroutine
try {
    client.mute("callId")
} catch (e: Error) {
    // Handle Error in muting call
}

Unmute ​

Re-enable the local microphone after muting.


// Callback
client.unmute("callId") {
    it?.let { err ->
        // Handle Error in unmuting call
        println("Error in unmuting call: $err")
    }
}

// Coroutine
try {
    client.unmute("callId")
} catch (e: Error) {
    // Handle Error in unmuting call
}

onMute update event ​

Fires when mute state changes, including changes triggered by the remote side or server.


client.setOnMutedListener { call, legId, isMuted ->
    if (isMuted) {
        // leg is muted
        println("leg:$legId for call: $call was muted")
    } else {
        // leg is unmuted
        println("leg:$legId for call: $call was un-muted")
    }
}

Enable earmuff ​

Earmuff prevents the local user from hearing remote audio. Unlike mute, earmuff is applied server-side — the audio stream is suppressed before it reaches the client.


// Callback
client.enableEarmuff("callId") {
    it?.let { err ->
        // Handle Error in enabling earmuff
        println("Error in enabling earmuff: $err")
    }
}

// Coroutine
try {
    client.enableEarmuff("callId")
} catch (e: Error) {
    // Handle Error in enabling earmuff
}

Disable earmuff ​

Restore incoming audio after earmuffing.


// Callback
client.disableEarmuff("callId") {
    it?.let { err ->
        // Handle Error in disabling earmuff
        println("Error in disabling earmuff: $err")
    }
}

// Coroutine
try {
    client.disableEarmuff("callId")
} catch (e: Error) {
    // Handle Error in disabling earmuff
}

onEarmuff update event ​

Fires when earmuff state changes.


client.setOnEarmuffListener {call, legId, earmuffStatus ->
    if (earmuffStatus) {
        // earmuff enabled
        println("earmuff is enabled for leg:$legId with Call $call")
    } else {
        // earmuff disabled
        println("earmuff is disabled for leg:$legId with Call $call")
    }
}

Send DTMF ​

Send dual-tone multi-frequency signals during an active call. Valid digits are 0-9, *, and #. DTMF is commonly used for IVR navigation and phone-system interaction.


// Callback
client.sendDTMF("callId", "1234") {
    it?.let { err ->
        // Handle Error in sending DTMF
        println("Error in sending DTMF: $err")
    }
}

// Coroutine
try {
    client.sendDTMF("callId", "1234")
} catch (e: Error) {
    // Handle Error in sending DTMF
}

onDTMF update event ​

Fires when DTMF digits are received from the remote party.


client.setOnDTMFListener {call, legId, digits ->
    println("Received DTMF digits: $digits for leg:$legId with Call $call")
}

Enable noise suppression ​

Filter background noise out of the local microphone input.


// Callback
client.enableNoiseSuppression("callId") { err ->
    err?.let {
        println("Error enabling noise suppression: $it")
    } ?: println("Noise suppression successfully enabled")
}

// Coroutine
try {
    client.enableNoiseSuppression("callId")
} catch (e: Error) {
    println("Error enabling noise suppression: $e")
}

Disable noise suppression ​

Stop filtering background noise.


// Callback
client.disableNoiseSuppression("callId") { err ->
    err?.let {
        println("Error disabling noise suppression: $it")
    } ?: println("Noise suppression successfully disabled")
}

// Coroutine
try {
    client.disableNoiseSuppression("callId")
    println("Noise suppression successfully disabled")
} catch (e: Error) {
    println("Error disabling noise suppression: $e")
}

To apply noise suppression to every call rather than per call, set it on the client config — enableNoiseSuppression on Android and iOS, noiseSuppression on Web. It defaults to false on all three.

Enable auto gain control (Web) ​

Let the browser even out the volume of the microphone input, so a quiet speaker is raised and a loud one is not clipped.

const callId = 'callId';
await client.enableAutoGainControl(callId);

Disable auto gain control (Web) ​

Send the microphone input level unaltered.

const callId = 'callId';
await client.disableAutoGainControl(callId);

Enable echo cancellation (Web) ​

Stop audio played through the speakers being picked back up by the microphone and returned to the remote party as an echo.

const callId = 'callId';
await client.enableEchoCancellation(callId);

Disable echo cancellation (Web) ​

Only disable this when the input cannot produce echo — a headset, or a feed already echo-cancelled upstream.

const callId = 'callId';
await client.disableEchoCancellation(callId);

Web audio processing is experimental

The six Web audio processing actions are marked @experimental in the TypeScript definitions. Browsers enable all three constraints by default, so in most cases you only need these APIs to turn one off, or to turn it back on afterwards.

Built with VitePress.