Manage media and devices

Updated

Implement key workflow steps required to develop a fully functional video calling app

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 use-cases. 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.

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);

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);
// To mute remote users without unsubscribing, set the remote volume to 0
remoteUser.audioTrack.setVolume(0);

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);
});

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.

API reference

See also