For AI agents: see the complete documentation index at /llms.txt.
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 Video 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.
Mute and unmute users
To mute or unmute the local audio stream, call muteLocalAudioStream:
// Stop publishing the local audio stream
mRtcEngine.muteLocalAudioStream(true);
// Resume publishing the local audio stream
mRtcEngine.muteLocalAudioStream(false);// Stop publishing the local audio stream
mRtcEngine.muteLocalAudioStream(true)
// Resume publishing the local audio stream
mRtcEngine.muteLocalAudioStream(false)To mute or unmute a remote user, call muteRemoteAudioStream with the uid of the remote user:
// Stop subscribing to the audio stream of the remote user
mRtcEngine.muteRemoteAudioStream(remoteUid, true);
// Resume subscribing to the audio stream of the remote user
mRtcEngine.muteRemoteAudioStream(remoteUid, false);// Stop subscribing to the audio stream of the remote user
mRtcEngine.muteRemoteAudioStream(remoteUid, true)
// Resume subscribing to the audio stream of the remote user
mRtcEngine.muteRemoteAudioStream(remoteUid, false)To mute remote users without unsubscribing, set their playback volume to 0.
Adjust the playback volume
Call adjustPlaybackSignalVolume or adjustUserPlaybackSignalVolume to adjust the volume of the audio playback signal.
int volume = 50;
int uid = 123456;
// Set the local playback volume for all remote users
mRtcEngine.adjustPlaybackSignalVolume(volume);
// Set the local playback volume for a specific remote user. For example, a user with uid=123
mRtcEngine.adjustUserPlaybackSignalVolume(uid, volume);val volume = 50
val uid = 123456
// Set the local playback volume for all remote users
mRtcEngine.adjustPlaybackSignalVolume(volume)
// Set the local playback volume for a specific remote user (e.g., user with uid=123)
mRtcEngine.adjustUserPlaybackSignalVolume(uid, volume)Adjust the in-ear monitoring volume
During the process of audio capture, mixing, and playback, Agora enables you to adjust the in-ear monitoring volume. Enable and set the volume using enableInEarMonitoring and setInEarMonitoringVolume.
// Enable in-ear monitoring
mRtcEngine.enableInEarMonitoring(true);
int volume = 50;
// Adjust in-ear monitoring volume
mRtcEngine.setInEarMonitoringVolume(volume);// Enable in-ear monitoring
mRtcEngine.enableInEarMonitoring(true)
val volume = 50
// Adjust in-ear monitoring volume
mRtcEngine.setInEarMonitoringVolume(volume)Adjust the recording volume
Call adjustRecordingSignalVolume to adjust the volume of the audio recording signal.
ChannelMediaOptions options = new ChannelMediaOptions();
options.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER;
mRtcEngine.joinChannel(token, channelName, 1234, options);
// Adjust the recording signal volume to 50
int vol = 50;
mRtcEngine.adjustRecordingSignalVolume(vol);// Create ChannelMediaOptions and set client role
val options = ChannelMediaOptions().apply {
clientRoleType = Constants.CLIENT_ROLE_BROADCASTER
}
// Join channel
mRtcEngine.joinChannel(token, channelName, 1234, options)
// Adjust the recording signal volume to 50
val vol = 50
mRtcEngine.adjustRecordingSignalVolume(vol)When configuring audio settings, it's essential to understand the default behavior and the options available. Here are the key points to keep in mind:
- The SDK defaults to a device volume of
85when using the recording device to capture audio signals. - A volume of
0means mute, and a volume of255represents the maximum volume of the device. - If the SDK detects that the recording volume is too low in the current environment, it automatically increases the volume of the recording device.
- The volume of the recording device directly influences the global volume of the device.
- If the default recording device volume does not meet your requirements, adjust it by regulating the signal amplitude captured by the microphone or sound card.
Get volume information of users
Video SDK enables you to obtain the user IDs and corresponding volumes of the three users with the highest instantaneous volumes in a channel during the process of audio recording, mixing, and playback. You use the onAudioVolumeIndication callback to obtain this information. A returned uid of 0 in the callback indicates the local user.
private final IRtcEngineEventHandler mRtcEventHandler = new IRtcEngineEventHandler()
{
// ...
// Retrieve the user IDs of the three users with the highest instantaneous speaking volume,
// their respective volumes, and determine whether the local user is speaking.
@Override
public void onAudioVolumeIndication(AudioVolumeInfo[] speakers, int totalVolume) {
}
};private val mRtcEventHandler = object : IRtcEngineEventHandler() {
// Retrieve the user IDs of the three users with the highest instantaneous speaking volume,
// their respective volumes, and determine whether the local user is speaking.
override fun onAudioVolumeIndication(speakers: Array<AudioVolumeInfo>?, totalVolume: Int) {
// Your implementation here
}
}Note
Call enableAudioVolumeIndication to enable reporting of the users' volume in the callback.
// Enable the onAudioVolumeIndication callback
mRtcEngine.enableAudioVolumeIndication(1000, 3, true);// Enable the onAudioVolumeIndication callback
mRtcEngine.enableAudioVolumeIndication(1000, 3, true)Use one or more of the following volume control methods to adjust volume settings.
Mute and unmute users
To mute or unmute the local audio stream, call muteLocalAudioStream:
// Stop publishing the local audio stream
engine.muteLocalAudioStream(true);
// Resume publishing the local audio stream
engine.muteLocalAudioStream(true);To mute or unmute a remote user, call muteRemoteAudioStream with the uid of the remote user:
// Stop subscribing to the audio stream of the remote user
engine.muteRemoteAudioStream(remoteUid, true);
// Resume subscribing to the audio stream of the remote user
engine.muteRemoteAudioStream(remoteUid, false);To mute remote users without unsubscribing, set their playback volume to 0.
Adjust the playback volume
Call adjustPlaybackSignalVolume or adjustUserPlaybackSignalVolume to adjust the volume of the audio playback signal.
// Set the local playback volume to 50 for all remote users
engine.adjustPlaybackSignalVolume(50);
// Set the local playback volume for a specific remote user. For example, user with uid 12
engine.adjustUserPlaybackSignalVolume(12, 50);Adjust the recording volume
Call adjustRecordingSignalVolume to adjust the volume of the audio recording signal.
// Adjust the recording signal volume to 50
engine.adjustRecordingSignalVolume(50);When configuring audio settings, it's essential to understand the default behavior and the options available. Here are the key points to keep in mind:
- The SDK defaults to a device volume of
85when using the recording device to capture audio signals. - A volume of
0means mute, and a volume of255represents the maximum volume of the device. - If the SDK detects that the recording volume is too low in the current environment, it automatically increases the volume of the recording device.
- The volume of the recording device directly influences the global volume of the device.
- If the default recording device volume does not meet your requirements, adjust it by regulating the signal amplitude captured by the microphone or sound card.
Get volume information of users
Video SDK enables you to obtain the user IDs and corresponding volumes of the three users with the highest instantaneous volumes in a channel during the process of audio recording, mixing, and playback. You use the onAudioVolumeIndication callback to obtain this information. A returned uid of 0 in the callback indicates the local user.
Note
Call enableAudioVolumeIndication to enable reporting of the users' volume in the callback.
// Retrieve the user IDs of the three users with the highest instantaneous speaking volume,
// their respective volumes, and determine whether the local user is speaking.
onAudioVolumeIndication?(
connection: RtcConnection,
speakers: AudioVolumeInfo[],
speakerNumber: number,
totalVolume: number
): void;Use one or more of the following volume control methods to adjust volume settings.
Mute and unmute users
To mute or unmute the local audio stream, call muteLocalAudioStream:
// Stop publishing the local audio stream
_rtcEngine.muteLocalAudioStream(true);
// Resume publishing the local audio stream
_rtcEngine.muteLocalAudioStream(false);To mute or unmute a remote user, call muteRemoteAudioStream with the uid of the remote user:
// Stop subscribing to the audio stream of the remote user
_rtcEngine.muteRemoteAudioStream(remoteUid, true);
// Resume subscribing to the audio stream of the remote user
_rtcEngine.muteRemoteAudioStream(remoteUid, false);To mute remote users without unsubscribing, set their playback volume to 0.
Adjust the playback volume
Call adjustPlaybackSignalVolume or adjustUserPlaybackSignalVolume to adjust the volume of the audio playback signal.
const int volume = 50;
// Set the local playback volume to 50 for all remote users
await _rtcEngine.adjustPlaybackSignalVolume(volume);
// Set the local playback volume for a specific remote user. For example, user with uid 1000
await _rtcEngine.adjustUserPlaybackSignalVolume(uid: 1000, volume: volume);Adjust the recording volume
Call adjustRecordingSignalVolume to adjust the volume of the audio recording signal.
// Adjust the recording signal volume to 50
int vol = 50;
await _rtcEngine.adjustRecordingSignalVolume(vol);When configuring audio settings, it's essential to understand the default behavior and the options available. Here are the key points to keep in mind:
- The SDK defaults to a device volume of
85when using the recording device to capture audio signals. - A volume of
0means mute, and a volume of255represents the maximum volume of the device. - If the SDK detects that the recording volume is too low in the current environment, it automatically increases the volume of the recording device.
- The volume of the recording device directly influences the global volume of the device.
- If the default recording device volume does not meet your requirements, adjust it by regulating the signal amplitude captured by the microphone or sound card.
Get volume information of users
Video SDK enables you to obtain the user IDs and corresponding volumes of the three users with the highest instantaneous volumes in a channel during the process of audio recording, mixing, and playback. You use the onAudioVolumeIndication callback to obtain this information. A returned uid of 0 in the callback indicates the local user.
Note
Call enableAudioVolumeIndication to enable reporting of the users' volume in the callback.
// Retrieve the user IDs of the three users with the highest instantaneous speaking volume,
// their respective volumes, and determine whether the local user is speaking.
_rtcEngine.registerEventHandler(RtcEngineEventHandler(
onAudioVolumeIndication: (RtcConnection connection,
List<AudioVolumeInfo> speakers, int speakerNumber, int totalVolume) {
logSink.log(
'[onAudioVolumeIndication] speakers: ${speakers.toString()}, speakerNumber: $speakerNumber, totalVolume: $totalVolume');
}
));Use one or more of the following volume control methods to adjust volume settings.
Mute and unmute users
- To mute or unmute the local audio stream, call
muteLocalAudioStream:
[agoraKit muteLocalAudioStream:YES];// Stop publishing the local audio stream
agoraKit.muteLocalAudioStream(true)
// Resume publishing the local audio stream
agoraKit.muteLocalAudioStream(false)- To mute or unmute a remote user, call
muteRemoteAudioStreamwith theuidof the remote user:
[agoraKit muteRemoteAudioStream:remoteUid mute:YES];// Stop subscribing to the audio stream of the remote user
agoraKit.muteRemoteAudioStream(remoteUid, mute: true)
// Resume subscribing to the audio stream of the remote user
agoraKit.muteRemoteAudioStream(remoteUid, mute: false)To mute remote users without unsubscribing, set their playback volume to 0.
Adjust the playback volume
Call adjustPlaybackSignalVolume or adjustUserPlaybackSignalVolume to adjust the volume of the audio playback signal.
// Set the volume of all remote users played locally
[agoraKit adjustPlaybackSignalVolume: 50];
// Set the local playback volume for a specific remote user.
[agoraKit adjustUserPlaybackSignalVolume: uid, volume: 50];// Set the volume of all remote users played locally
agoraKit.adjustPlaybackSignalVolume(50)
// Set the local playback volume for a specific remote user
agoraKit.adjustUserPlaybackSignalVolume(uid, volume: 50)Adjust the in-ear monitoring volume
During the process of audio capture, mixing, and playback, Agora enables you to adjust the volume of in-ear monitoring. Enable and set the in-ear monitoring through enableInEarMonitoring and setInEarMonitoringVolume.
// Enable in-ear monitoring
[agoraKit enableInEarMonitoring:true];
// Adjust in-ear monitoring volume
[agoraKit setInEarMonitoringVolume:50];// Enable in-ear monitoring
agoraKit.enableInEarMonitoring(true)
// Adjust in-ear monitoring volume
agoraKit.setInEarMonitoringVolume(50)Adjust the recording volume
Call adjustRecordingSignalVolume to adjust the volume of the audio recording signal.
// Adjust the recording signal volume
[agoraKit adjustRecordingSignalVolume: 50];// Adjust the recording signal volume
agoraKit.adjustRecordingSignalVolume(50)When configuring audio settings, it's essential to understand the default behavior and the options available. Here are the key points to keep in mind:
- The SDK defaults to a device volume of
85when using the recording device to capture audio signals. - A volume of
0means mute, and a volume of255represents the maximum volume of the device. - If the SDK detects that the recording volume is too low in the current environment, it automatically increases the volume of the recording device.
- The volume of the recording device directly influences the global volume of the device.
- If the default recording device volume does not meet your requirements, adjust it by regulating the signal amplitude captured by the microphone or sound card.
Get volume information of users
Video SDK enables you to obtain the user IDs and corresponding volumes of the three users with the highest instantaneous volumes in a channel during the process of audio recording, mixing, and playback. You use reportAudioVolumeIndicationOfSpeakers callback to obtain this information. A returned uid of 0 in the callback indicates the local user.
Note
Call enableAudioVolumeIndication to enable reporting of the users' volume in the callback.
// Retrieve the user IDs of the three users with the highest instantaneous speaking volume,
// their respective volumes, and determine whether the local user is speaking.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine
reportAudioVolumeIndicationOfSpeakers:(NSArray<AgoraRtcAudioVolumeInfo *> *_Nonnull)speakers
totalVolume:(NSInteger)totalVolume {
}// Retrieve the user IDs of the three users with the highest instantaneous speaking volume,
// their respective volumes, and determine whether the local user is speaking.
func rtcEngine(
_ engine: AgoraRtcEngineKit,
reportAudioVolumeIndicationOfSpeakers speakers: [AgoraRtcAudioVolumeInfo],
totalVolume: Int
) {
}
// Enable the reportAudioVolumeIndicationOfSpeakers callback
agoraKit.enableAudioVolumeIndication(200, smooth: 3, reportVad: true)Use one or more of the following volume control methods to adjust volume settings.
Mute and unmute users
- To mute or unmute the local audio stream, call
muteLocalAudioStream:
[agoraKit muteLocalAudioStream:YES];// Stop publishing the local audio stream
agoraKit.muteLocalAudioStream(true)
// Resume publishing the local audio stream
agoraKit.muteLocalAudioStream(false)- To mute or unmute a remote user, call
muteRemoteAudioStreamwith theuidof the remote user:
[agoraKit muteRemoteAudioStream:remoteUid mute:YES];// Stop subscribing to the audio stream of the remote user
agoraKit.muteRemoteAudioStream(remoteUid, mute: true)
// Resume subscribing to the audio stream of the remote user
agoraKit.muteRemoteAudioStream(remoteUid, mute: false)To mute remote users without unsubscribing, set their playback volume to 0.
Adjust the playback volume
Call adjustPlaybackSignalVolume or adjustUserPlaybackSignalVolume to adjust the volume of the audio playback signal.
// Set the volume of all remote users played locally
[agoraKit adjustPlaybackSignalVolume: 50];
// Set the local playback volume for a specific remote user.
[agoraKit adjustUserPlaybackSignalVolume: uid, volume: 50];// Set the volume of all remote users played locally
agoraKit.adjustPlaybackSignalVolume(50)
// Set the local playback volume for a specific remote user
agoraKit.adjustUserPlaybackSignalVolume(uid, volume: 50)Adjust the in-ear monitoring volume
During the process of audio capture, mixing, and playback, Agora enables you to adjust the volume of in-ear monitoring. Enable and set the in-ear monitoring through enableInEarMonitoring and setInEarMonitoringVolume.
// Enable in-ear monitoring
[agoraKit enableInEarMonitoring:true];
// Adjust in-ear monitoring volume
[agoraKit setInEarMonitoringVolume:50];// Enable in-ear monitoring
agoraKit.enableInEarMonitoring(true)
// Adjust in-ear monitoring volume
agoraKit.setInEarMonitoringVolume(50)Adjust the recording volume
Call adjustRecordingSignalVolume to adjust the volume of the audio recording signal.
// Adjust the recording signal volume
[agoraKit adjustRecordingSignalVolume: 50];// Adjust the recording signal volume
agoraKit.adjustRecordingSignalVolume(50)When configuring audio settings, it's essential to understand the default behavior and the options available. Here are the key points to keep in mind:
- The SDK defaults to a device volume of
85when using the recording device to capture audio signals. - A volume of
0means mute, and a volume of255represents the maximum volume of the device. - If the SDK detects that the recording volume is too low in the current environment, it automatically increases the volume of the recording device.
- The volume of the recording device directly influences the global volume of the device.
- If the default recording device volume does not meet your requirements, adjust it by regulating the signal amplitude captured by the microphone or sound card.
Get volume information of users
Video SDK enables you to obtain the user IDs and corresponding volumes of the three users with the highest instantaneous volumes in a channel during the process of audio recording, mixing, and playback. You use reportAudioVolumeIndicationOfSpeakers callback to obtain this information. A returned uid of 0 in the callback indicates the local user.
Note
Call enableAudioVolumeIndication to enable reporting of the users' volume in the callback.
// Retrieve the user IDs of the three users with the highest instantaneous speaking volume,
// their respective volumes, and determine whether the local user is speaking.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine
reportAudioVolumeIndicationOfSpeakers:(NSArray<AgoraRtcAudioVolumeInfo *> *_Nonnull)speakers
totalVolume:(NSInteger)totalVolume {
}// Retrieve the user IDs of the three users with the highest instantaneous speaking volume,
// their respective volumes, and determine whether the local user is speaking.
func rtcEngine(
_ engine: AgoraRtcEngineKit,
reportAudioVolumeIndicationOfSpeakers speakers: [AgoraRtcAudioVolumeInfo],
totalVolume: Int
) {
}
// Enable the reportAudioVolumeIndicationOfSpeakers callback
agoraKit.enableAudioVolumeIndication(200, smooth: 3, reportVad: true)Use one or more of the following volume control methods to adjust volume settings.
Adjust the capture volume of remote audio
To set the volume, mute, or unmute a remote user, call setVolume on the remote audio track:
// Mute remote audio
const muteRemoteAudio = (audioTrack: IRemoteAudioTrack | null) => {
if (!audioTrack) return;
audioTrack.setVolume(0);
};
// Unmute remote audio
const unmuteRemoteAudio = (audioTrack: IRemoteAudioTrack | null) => {
if (!audioTrack) return;
audioTrack.setVolume(100); // Set to a reasonable volume level
};Adjust the capture volume of local audio
To set the capture volume, mute, or unmute the local user, call setVolume on the local audio track:
// Mute local audio
const muteLocalAudio = (audioTrack: IMicrophoneAudioTrack | null) => {
if (!audioTrack) return;
audioTrack.setVolume(0);
};
// Unmute local audio
const unmuteLocalAudio = (audioTrack: IMicrophoneAudioTrack | null) => {
if (!audioTrack) return;
audioTrack.setVolume(100); // Set the volume to a reasonable volume level
};The following example demonstrates how to mute and unmute local and remote users using useLocalMicrophoneTrack and useRemoteUsers.
const { localMicrophoneTrack } = useLocalMicrophoneTrack(micOn);
const remoteUsers = useRemoteUsers();
return (
<>
<div>
<button
onClick={() => muteLocalAudio(localMicrophoneTrack)}
>
Mute local user
</button>
<button
onClick={() => unmuteLocalAudio(localMicrophoneTrack)}
>
Unmute local user
</button>
<button
onClick={() => muteRemoteAudio(remoteUsers[0].audioTrack || null)}
>
Mute remote user
</button>
<button
onClick={() => unmuteRemoteAudio(remoteUsers[0].audioTrack || null)}
>
Unmute remote user
</button>
</div>
</>
);Get volume information of users
The Video SDK provides the ability to monitor the volume level of users using the useVolumeLevel hook. To get the audio volume level, pass the respective audio track (local or remote) to the hook:
// Component to track and display the local user's audio volume level
const AudioVolumeTracker = ({ audioTrack }: { audioTrack?: IMicrophoneAudioTrack }) => {
const volumeLevel = useVolumeLevel(audioTrack);
return (
<div>
<label>Current Volume Level: {volumeLevel}</label>
</div>
);
};
// Component to track and display the remote user's audio volume level
const RemoteAudioVolumeTracker = ({ audioTrack }: { audioTrack?: IRemoteAudioTrack }) => {
const volumeLevel = useVolumeLevel(audioTrack);
return (
<div>
<label>Remote User's Volume Level: {volumeLevel}</label>
</div>
);
};How to use:
const { localMicrophoneTrack } = useLocalMicrophoneTrack();
// Display the volume level of the local user
<AudioVolumeTracker audioTrack={localMicrophoneTrack} />;
const remoteUsers = useRemoteUsers();
// Display the volume level of the first remote user
<RemoteAudioVolumeTracker audioTrack={remoteUsers[0]?.audioTrack} />;Use one or more of the following volume control methods to adjust volume settings.
Mute and unmute users
To mute or unmute the local audio stream, call muteLocalAudioStream:
// Stop publishing the local audio stream
engine.muteLocalAudioStream(true);
// Resume publishing the local audio stream
engine.muteLocalAudioStream(false);To mute or unmute a remote user, call muteRemoteAudioStream with the uid of the remote user:
// Stop subscribing to the audio stream of the remote user
engine.muteRemoteAudioStream(remoteUid, true);
// Resume subscribing to the audio stream of the remote user
engine.muteRemoteAudioStream(remoteUid, false);To mute remote users without unsubscribing, set their playback volume to 0.
Adjust the playback volume
Call adjustPlaybackSignalVolume or adjustUserPlaybackSignalVolume to adjust the volume of the audio playback signal.
// Set the local playback volume to 50 for all remote users
engine.adjustPlaybackSignalVolume(50);
// Set the local playback volume for a specific remote user. For example, user with uid 12
engine.adjustUserPlaybackSignalVolume(12, 50);Adjust the recording volume
Call adjustRecordingSignalVolume to adjust the volume of the audio recording signal.
// Adjust the recording signal volume to 50
engine.adjustRecordingSignalVolume(50);When configuring audio settings, it's essential to understand the default behavior and options available. Here are the key points to keep in mind:
- The SDK defaults to a device volume of
85when using the recording device to capture audio signals. - A volume of
0means mute, and a volume of255represents the maximum volume of the device. - If the SDK detects that the recording volume is too low in the current environment, it automatically increases the volume of the recording device.
- The volume of the recording device directly influences the global volume of the device.
- If the default recording device volume does not meet your requirements, adjust it by regulating the signal amplitude captured by the microphone or sound card.
Get volume information of users
Video SDK enables you to obtain the user IDs and corresponding volumes of the three users with the highest instantaneous volumes in a channel during the process of audio recording, mixing, and playback. You use the onAudioVolumeIndication callback to obtain this information. A returned uid of 0 in the callback indicates the local user.
Note
Call enableAudioVolumeIndication to enable reporting of the users' volume in the callback.
// Retrieve the user IDs of the three users with the highest instantaneous speaking volume,
// their respective volumes, and determine whether the local user is speaking.
onAudioVolumeIndication?(
connection: RtcConnection,
speakers: AudioVolumeInfo[],
speakerNumber: number,
totalVolume: number
): void;Use one or more of the following volume control methods to adjust volume settings.
Mute and unmute users
To mute or unmute the local audio stream, call MuteLocalAudioStream:
// Stop publishing the local audio stream
RtcEngine.MuteLocalAudioStream(true);
// Resume publishing the local audio stream
RtcEngine.MuteLocalAudioStream(false);To mute or unmute a remote user, call MuteRemoteAudioStream with the uid of the remote user:
// Stop subscribing to the audio stream of the remote user
RtcEngine.MuteRemoteAudioStream(remoteUid, true);
// Resume subscribing to the audio stream of the remote user
RtcEngine.MuteRemoteAudioStream(remoteUid, false);To mute remote users without unsubscribing, set their playback volume to 0.
Adjust the playback volume
Call AdjustPlaybackSignalVolume or AdjustUserPlaybackSignalVolume to adjust the volume of the audio playback signal.
// Set the volume for all remote users' playback locally to 50
RtcEngine.AdjustPlaybackSignalVolume(50);
// Set the playback volume for the remote user with the uid of 12 locally to 50
RtcEngine.AdjustUserPlaybackSignalVolume(12, 50);Adjust the recording volume
Call AdjustRecordingSignalVolume to adjust the volume of the audio recording signal.
// Adjust the recording signal volume to 50
RtcEngine.AdjustRecordingSignalVolume(50);When configuring audio settings, it's essential to understand the default behavior and the options available. Here are the key points to keep in mind:
- The SDK defaults to a device volume of
85when using the recording device to capture audio signals. - A volume of
0means mute, and a volume of255represents the maximum volume of the device. - If the SDK detects that the recording volume is too low in the current environment, it automatically increases the volume of the recording device.
- The volume of the recording device directly influences the global volume of the device.
- If the default recording device volume does not meet your requirements, adjust it by regulating the signal amplitude captured by the microphone or sound card.
Get volume information of users
Video SDK enables you to obtain the user IDs and corresponding volumes of the three users with the highest instantaneous volumes in a channel during the process of audio recording, mixing, and playback. You use the OnAudioVolumeIndication callback to obtain this information. A returned uid of 0 in the callback indicates the local user.
Note
Call EnableAudioVolumeIndication to enable reporting of the users' volume in the callback.
RtcEngine = Agora.Rtc.RtcEngine.CreateAgoraRtcEngine();
UserEventHandler handler = new UserEventHandler(this);
RtcEngineContext context = new RtcEngineContext(
_appID,
0,
CHANNEL_PROFILE_TYPE.CHANNEL_PROFILE_LIVE_BROADCASTING,
AUDIO_SCENARIO_TYPE.AUDIO_SCENARIO_DEFAULT
);
RtcEngine.Initialize(context);
// Set up listener callback
RtcEngine.InitEventHandler(handler);
// Enable volume indication
RtcEngine.EnableAudioVolumeIndication(1, 1, true);
class UserEventHandler : IRtcEngineEventHandler
{
// This callback is triggered at the interval set in EnableAudioVolumeIndication and reports the three users with the highest instant volume in the channel
public override void OnAudioVolumeIndication(
RtcConnection connection,
AudioVolumeInfo[] speakers,
uint speakerNumber,
int totalVolume
) { }
}Use one or more of the following volume control methods to adjust volume settings.
Mute and unmute users
To mute or unmute the local audio stream, call muteLocalAudioStream:
// Stop publishing the local audio stream
m_rtcEngine->muteLocalAudioStream(true);
// Resume publishing the local audio stream
m_rtcEngine->muteLocalAudioStream(false);To mute or unmute a remote user, call muteRemoteAudioStream with the uid of the remote user:
// Stop subscribing to the audio stream of the remote user
m_rtcEngine->muteRemoteAudioStream(remoteUid, true);
// Resume subscribing to the audio stream of the remote user
m_rtcEngine->muteRemoteAudioStream(remoteUid, false);To mute remote users without unsubscribing, set their playback volume to 0.
Adjust the playback volume
Call adjustPlaybackSignalVolume or adjustUserPlaybackSignalVolume to adjust the volume of the audio playback signal.
int volume = 50;
int uid = 123456;
// Set the local playback volume for all remote users
m_rtcEngine->adjustPlaybackSignalVolume(volume);
// Set the local playback volume for a specific remote user. For example, user 123456
m_rtcEngine->adjustUserPlaybackSignalVolume(uid, volume)Adjust the recording volume
Call adjustRecordingSignalVolume to adjust the volume of the audio recording signal.
// Adjust the recording signal volume to 50
int vol = 50;
m_rtcEngine->adjustRecordingSignalVolume(vol);When configuring audio settings, it's essential to understand the default behavior and the options available. Here are the key points to keep in mind:
- The SDK defaults to a device volume of
85when using the recording device to capture audio signals. - A volume of
0means mute, and a volume of255represents the maximum volume of the device. - If the SDK detects that the recording volume is too low in the current environment, it automatically increases the volume of the recording device.
- The volume of the recording device directly influences the global volume of the device.
- If the default recording device volume does not meet your requirements, adjust it by regulating the signal amplitude captured by the microphone or sound card.
Get volume information of users
Video SDK enables you to obtain the user IDs and corresponding volumes of the three users with the highest instantaneous volumes in a channel during the process of audio recording, mixing, and playback. You use the onAudioVolumeIndication callback to obtain this information. A returned uid of 0 in the callback indicates the local user.
// Retrieve the user IDs of the three users with the highest instantaneous speaking volume,
// their respective volumes, and determine whether the local user is speaking.
void CAudioVolumeEventHandler::onAudioVolumeIndication(const AudioVolumeInfo* speakers, unsigned int speakerNumber, int totalVolume){
}
// Enable the onAudioVolumeIndication callback
m_rtcEngine->enableAudioVolumeIndication(1000, 0, true);Note
Call enableAudioVolumeIndication to enable reporting of the users' volume in the callback.
Adjust playback volume
This section shows you how to adjust the audio playback signal volume using AdjustPlaybackSignalVolume.
-
Create UMG
Create a Slider widget named Slider_PlaybackSignalVolume for users to drag the volume bar to adjust the playback volume. In this example, set the minimum value to
0(mute) and the maximum value to100(original volume), as shown in the following figure: -
Bind UI Events
Create a Bind Event to On Value Changed node and connect it to the Slider_PlaybackSignalVolume widget and the OnPlaybackSignalVolumeValChanged callback. When users drag the volume bar to adjust the audio playback signal, the OnPlaybackSignalVolumeValChanged callback is triggered, as shown in the following figure:
-
Implement Callback Function
Create OnPlaybackSignalVolumeValChanged callback function with the following parameters:
Input parameter Data type Parameter description valueFloat Playback Volume When this callback is triggered, the specified playback volume is obtained and assigned to the Volume parameter of Adjust Playback Signal Volume. The AdjustPlaybackSignalVolume method is called to adjust the playback volume, as shown in the following figure:
Adjust recording volume
This section shows you how to adjust the audio recording signal volume using AdjustRecordingSignalVolume.
-
Create UMG
Create a Slider widget named Slider_RecordingSignalVolume to enable users to adjust the recording volume. For this example, set the minimum value to
0(mute) and the maximum value to100(original volume), as shown in the following figure: -
Bind UI Events
Create a Bind Event to On Value Changed node and connect it to the Slider_RecordingSignalVolume widget and the OnRecordingSignalVolumeValChanged callback. When users drag the volume bar to adjust the audio recording signal, the OnRecordingSignalVolumeValChanged callback is triggered, as shown in the following figure:
-
Implement UI Events
Create the OnRecordingSignalVolumeValChanged callback function with the following parameters:
Input parameter Data type Parameter description valueFloat Recording Volume When the callback is triggered, the specified recording volume is obtained and assigned to the Volume parameter of Adjust Recording Signal Volume. The AdjustRecordingSignalVolume method is called to adjust the recording volume, as shown in the following figure:
When configuring audio settings, it's essential to understand the default behavior and the options available. Here are the key points to keep in mind:
- The SDK defaults to a device volume of
85when using the recording device to capture audio signals. - A volume of
0means mute, and a volume of255represents the maximum volume of the device. - If the SDK detects that the recording volume is too low in the current environment, it automatically increases the volume of the recording device.
- The volume of the recording device directly influences the global volume of the device.
- If the default recording device volume does not meet your requirements, adjust it by regulating the signal amplitude captured by the microphone or sound card.
- The SDK defaults to a device volume of
Get volume information of users
Throughout the process of audio recording, mixing, and playback, you can obtain the user IDs and volumes of the three users with the highest instant volumes in the channel using the FOnAudioVolumeIndication callback. A returned uid of 0 represents the local user. You need to call the EnableAudioVolumeIndication method to activate the voice detection function to receive this callback.
-
Create UMG
Create a Button widget named Btn_EnableAudioIndication for users to control whether to enable the volume indication. As shown in the following figure:
-
Bind UI Events
Create a Bind Event to On Clicked node and connect it to the Btn_EnableAudioIndication widget and the OnVolumeIndicationClick callback. When users press the button to enable the volume indication, the OnVolumeIndicationClick callback is triggered, as shown in the following figure:
-
Implement UI Events
Create the OnVolumeIndicationClick callback function. When this callback is triggered, the Enable Audio Volume Indication method is called to enable volume indication. In this example, set the volume indication Interval to 200 milliseconds, the smoothing factor Smooth to 3, and check Report Vad to activate the voice detection function, as shown in the following figure:
-
Add Callback Event
-
Create the OnAudioVolumeIndication callback function with the following parameters:
Input parameter Data type Parameter description speakerFloat Structure Volume information of users, see FAudioVolumeInfo for details. totalVolumeInteger The total volume after mixing -
Enable listening to the OnAudioVolumeIndication callback, as shown in the following figure:
-
When the OnAudioVolumeIndication callback is triggered, print the received user volume information, as shown in the following figure:
-
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);
});Caution
If you set the volume too high using the signal volume adjustment methods, it may lead to audio distortion on some devices.
Use one or more of the following volume control methods to adjust volume settings.
Mute and unmute users
To mute or unmute the local audio stream, call muteLocalAudioStream:
// Stop publishing the local audio stream
m_rtcEngine->muteLocalAudioStream(true);
// Resume publishing the local audio stream
m_rtcEngine->muteLocalAudioStream(false);To mute or unmute a remote user, call muteRemoteAudioStream with the uid of the remote user:
// Stop subscribing to the audio stream of the remote user
m_rtcEngine->muteRemoteAudioStream(remoteUid, true);
// Resume subscribing to the audio stream of the remote user
m_rtcEngine->muteRemoteAudioStream(remoteUid, false);To mute remote users without unsubscribing, set their playback volume to 0.
Adjust the playback volume
Call adjustPlaybackSignalVolume or adjustUserPlaybackSignalVolume to adjust the volume of the audio playback signal.
int volume = 50;
int uid = 123456;
// Set the local playback volume for all remote users
m_rtcEngine->adjustPlaybackSignalVolume(volume);
// Set the local playback volume for a specific remote user. For example, user 123456
m_rtcEngine->adjustUserPlaybackSignalVolume(uid, volume)Adjust the recording volume
Call adjustRecordingSignalVolume to adjust the volume of the audio recording signal.
// Adjust the recording signal volume to 50
int vol = 50;
m_rtcEngine->adjustRecordingSignalVolume(vol);When configuring audio settings, it's essential to understand the default behavior and the options available. Here are the key points to keep in mind:
- The SDK defaults to a device volume of
85when using the recording device to capture audio signals. - A volume of
0means mute, and a volume of255represents the maximum volume of the device. - If the SDK detects that the recording volume is too low in the current environment, it automatically increases the volume of the recording device.
- The volume of the recording device directly influences the global volume of the device.
- If the default recording device volume does not meet your requirements, adjust it by regulating the signal amplitude captured by the microphone or sound card.
Get volume information of users
Video SDK enables you to obtain the user IDs and corresponding volumes of the three users with the highest instantaneous volumes in a channel during the process of audio recording, mixing, and playback. You use the onAudioVolumeIndication callback to obtain this information. A returned uid of 0 in the callback indicates the local user.
// Retrieve the user IDs of the three users with the highest instantaneous speaking volume,
// their respective volumes, and determine whether the local user is speaking.
void CAudioVolumeEventHandler::onAudioVolumeIndication(const AudioVolumeInfo* speakers, unsigned int speakerNumber, int totalVolume){
}
// Enable the onAudioVolumeIndication callback
m_rtcEngine->enableAudioVolumeIndication(1000, 0, true);Note
Call enableAudioVolumeIndication to enable reporting of the users' volume in the callback.
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
adjustRecordingSignalVolumeadjustPlaybackSignalVolumeadjustUserPlaybackSignalVolumeadjustAudioMixingPlayoutVolumeenableInEarMonitoring[2/2]setInEarMonitoringVolumeonAudioVolumeIndicationmuteLocalAudioStreammuteRemoteAudioStream
Sample projects
Agora offers the following open-source sample project for adjusting recording, playback, and in-ear monitoring volumes for your reference.
- GitHub: JoinChannelAudio
Frequently asked questions
API reference
adjustRecordingSignalVolumeadjustPlaybackSignalVolumeadjustUserPlaybackSignalVolumeadjustAudioMixingPlayoutVolumeonAudioVolumeIndicationmuteLocalAudioStreammuteRemoteAudioStream
Sample projects
Agora offers the following open-source sample project for adjusting recording, playback, and in-ear monitoring volumes for your reference:
- GitHub: JoinChannelAudio
For adjusting the playback volume of mixing or audio effect files, refer to the following sample project:
- GitHub: AudioMixing
Frequently asked questions
API reference
adjustRecordingSignalVolumeadjustPlaybackSignalVolumeadjustUserPlaybackSignalVolumeadjustAudioMixingPlayoutVolumeonAudioVolumeIndicationmuteLocalAudioStreammuteRemoteAudioStream
Sample projects
Agora offers the following open-source sample project for adjusting recording, playback, and in-ear monitoring volumes for your reference:
- GitHub: join_channel_audio.dart
For adjusting the playback volume of mixing or audio effect files, refer to the following sample project:
- GitHub: audio_mixing.dart
Frequently asked questions
API reference
adjustRecordingSignalVolumeadjustPlaybackSignalVolumeadjustUserPlaybackSignalVolumeadjustAudioMixingPlayoutVolumeenableInEarMonitoringsetInEarMonitoringVolumeenableaudiovolumeindicationmuteLocalAudioStreammuteRemoteAudioStream
Sample projects
Agora offers the following open-source sample project for adjusting recording, playback, and in-ear monitoring volumes for your reference:
- GitHub: JoinChannelAudio
For adjusting the playback volume of mixing or audio effect files, refer to the following sample project:
- GitHub: AudioMixing
Frequently asked questions
API reference
setdevicevolumeadjustRecordingSignalVolumeadjustPlaybackSignalVolumeadjustUserPlaybackSignalVolumeadjustAudioMixingPlayoutVolumeenableaudiovolumeindicationmuteLocalAudioStreammuteRemoteAudioStream
Sample projects
Agora offers the following open-source sample project for adjusting recording, playback, and in-ear monitoring volumes for your reference:
- GitHub: JoinChannelAudio
For adjusting the playback volume of mixing or audio effect files, refer to the following sample project:
- GitHub: AudioMixing
Frequently asked questions
API reference
Sample projects
Agora offers the following open-source sample project for monitoring audio volume for your reference.
- GitHub: useVolumeLevel
API reference
adjustRecordingSignalVolumeadjustPlaybackSignalVolumeadjustUserPlaybackSignalVolumeadjustAudioMixingPlayoutVolumeonAudioVolumeIndicationmuteLocalAudioStreammuteRemoteAudioStream
Sample projects
Agora offers the following open-source sample project for adjusting recording, playback, and in-ear monitoring volumes for your reference:
- GitHub: JoinChannelAudio
For adjusting the playback volume of mixing or audio effect files, refer to the following sample project:
- GitHub: AudioMixing
Frequently asked questions
API reference
AdjustRecordingSignalVolumeAdjustPlaybackSignalVolumeAdjustUserPlaybackSignalVolumeAdjustAudioMixingPlayoutVolumeOnAudioVolumeIndicationMuteLocalAudioStreamMuteRemoteAudioStream
Sample projects
Agora offers the following open-source sample project for adjusting recording, playback, and in-ear monitoring volumes for your reference:
- GitHub: AudioMixing
Frequently asked questions
API reference
adjustRecordingSignalVolumeadjustPlaybackSignalVolumeadjustUserPlaybackSignalVolumeadjustAudioMixingPlayoutVolumeonAudioVolumeIndicationmuteLocalAudioStreammuteRemoteAudioStream
Sample project
Agora provides an open source sample project for your reference. Download or view the SDK API-Example source code for a more detailed example.
Frequently asked questions
Sample projects
Agora provides an open-source Blueprint sample project on GitHub for your reference. To learn how to implement call volume adjustment, refer to JoinChannelAudio in the sample project.
Frequently asked questions
API reference
API reference
API reference
adjustRecordingSignalVolumeadjustPlaybackSignalVolumeadjustUserPlaybackSignalVolumeadjustAudioMixingPlayoutVolumeonAudioVolumeIndicationmuteLocalAudioStreammuteRemoteAudioStream
Sample projects
Agora offers the following open-source sample project for adjusting recording, playback, and in-ear monitoring volumes for your reference:
- GitHub: AudioVolume
For adjusting the playback volume of mixing or audio effect files, refer to the following sample project:
- GitHub: AudioMixing or AudioEffect
