Skip to main content
Android
iOS
macOS
Web
Windows
Electron
Flutter
React Native
Python
React JS
Unity
Unreal Engine
Unreal (Blueprint)

Volume control and mute

This page shows you how to configure volume settings for audio recording, audio playback, and for the playback of music files.

Understand the tech

Agora Voice SDK supports adjusting the audio volume for both recording and playback to meet practical application scenarios. For example, during a two-person call, you can mute a remote user by adjusting the playback volume setting to 0.

Prerequisites

Ensure that you have implemented the SDK quickstart in your project.

Implement volume control

Use one or more of the following volume control methods to adjust volume settings.

The Agora SDK provides a setVolume method for both local and remote audio track objects to adjust the volume of local audio capture and remote audio playback.

Adjust the playback volume of remote audio

In this example, remoteUser refers to a subscribed remote user object.

// Reduce the volume by half
remoteUser.audioTrack.setVolume(50);
// Use the original volume
remoteUser.audioTrack.setVolume(100);
// Set the remote volume to 0
remoteUser.audioTrack.setVolume(0);
Copy

Mute the local audio stream

To mute or unmute the local audio track, call setMuted or setEnabled:

// Mute the local audio stream
localAudioTrack.setMuted(true);

// Unmute the local audio stream
localAudioTrack.setMuted(false);
Copy

Adjust the capture volume of local audio

In this example, localAudioTrack is the local audio track object you created.

AgoraRTC.createMicrophoneAudioTrack().then(localAudioTrack => {
// Reduce microphone volume by half
localAudioTrack.setVolume(50);
// Double the microphone volume
localAudioTrack.setVolume(200);
// Set the microphone volume to 0
localAudioTrack.setVolume(0);
});
Copy
Caution
If you set the volume too high using the signal volume adjustment methods, it may lead to audio distortion on some devices.

Reference

This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.

Voice Calling