RtcDeviceManager
The RTC device manager class, which manages the audio and video devices in the system.
enumerateAudioPlaybackDevices
Enumerates the audio playback devices.
Future<List<MediaDeviceInfo>> enumerateAudioPlaybackDevices()
Returns
- Success: Returns a MediaDeviceInfo list that contains the device ID and device name of all the audio playback devices.
- Failure: null.
enumerateAudioRecordingDevices
Enumerates the audio capture devices.
Future<List<MediaDeviceInfo>> enumerateAudioRecordingDevices()
Returns
- Success: Returns a MediaDeviceInfo list that contains the device ID and device name of all the audio recording devices.
- Failure: null.
setAudioPlaybackDevice
Sets the audio playback device.
Future<void> setAudioPlaybackDevice(String deviceId)
Parameters
- deviceId
-
The ID of the audio playback device. You can get the device ID by calling enumerateAudioPlaybackDevices. Plugging or unplugging the audio device does not change the device ID.
setAudioRecordingDevice
Sets the audio capture device.
Future<void> setAudioRecordingDevice(String deviceId)
Parameters
- deviceId
-
The ID of the audio capture device. You can get the device ID by calling enumerateAudioRecordingDevices. Plugging or unplugging the audio device does not change the device ID.
startAudioPlaybackDeviceTest
Starts the audio playback device test.
Future<void> startAudioPlaybackDeviceTest(String testAudioFilePath)
This method tests whether the audio playback device works properly. Once a user starts the test, the SDK plays an audio file specified by the user. If the user can hear the audio, the playback device works properly.
-
audioVolumeIndication
and
audioDeviceTestVolumeIndication
when you call this method before joining the channel, with
the following values:
-
uid = 1
andvolume
in audioVolumeIndication. -
volumeType = AudioTestPlaybackVolume(1)
andvolume
in audioDeviceTestVolumeIndication.
-
-
audioDeviceTestVolumeIndication
when you call this method after joining a channel, which
reports
volumeType = AudioTestPlaybackVolume(1)
andvolume
.
- Calling this method after joining a channel tests the audio capturing device that the SDK is using.
- After calling startRecordingDeviceTest, you must call stopAudioPlaybackDeviceTest to stop the test.
Parameters
- testAudioFilePath
-
The path of the audio file for the audio playback device test in UTF-8.
stopAudioPlaybackDeviceTest
Stops the audio playback device test.
Future<void> stopAudioPlaybackDeviceTest()
This method stops the audio playback device test. You must call this method to stop the test after calling the startAudioPlaybackDeviceTest method.
startAudioRecordingDeviceTest
Starts the audio capture device test.
Future<void> startAudioRecordingDeviceTest(int indicationInterval)
This method tests whether the audio capturing device works properly.
-
audioVolumeIndication
and
audioDeviceTestVolumeIndication
when you call this method before joining the channel, with
the following values:
-
uid = 0
andvolume
in audioVolumeIndication. -
volumeType = AudioTestRecordingVolume(0)
andvolume
in audioDeviceTestVolumeIndication.
-
-
audioDeviceTestVolumeIndication
when you call this method after joining a channel, which
reports
volumeType = AudioTestRecordingVolume(0)
andvolume
.
-
When you call this method after joining a channel, ensure
the audio capturing device is on (
enableLocalAudio
is set as
true
); otherwise, the method call fails, and the SDK triggers the error callback withERR_ADM_START_RECORDING(1012)
. - Calling this method after joining a channel tests the audio capturing device that the SDK is using.
- After calling startRecordingDeviceTest, you must call stopAudioRecordingDeviceTest to stop the test.
Parameters
- indicationInterval
- The time interval (ms) at which the SDK triggers the audioVolumeIndication or audioDeviceTestVolumeIndication callback. Agora recommends a setting greater than 200 ms. This value must not be less than 10 ms; otherwise, you can not receive the audioVolumeIndication or audioDeviceTestVolumeIndication callback.
stopAudioRecordingDeviceTest
Stops the audio capture device test.
Future<void> stopAudioRecordingDeviceTest()
This method stops the audio capture device test. You must call this method to stop the test after calling the startAudioRecordingDeviceTest method.
getAudioPlaybackDevice
Retrieves the audio playback device associated with the device ID.
Future<String?> getAudioPlaybackDevice()
Returns
The current audio playback device.
getAudioPlaybackDeviceInfo
Retrieves the audio playback device information associated with the device ID and device name.
Future<MediaDeviceInfo?> getAudioPlaybackDeviceInfo()
Returns
A MediaDeviceInfo class, which includes the device ID and the device name.
getAudioRecordingDevice
Gets the current audio recording device.
Future<String?> getAudioRecordingDevice()
Returns
The current audio recording device.
getAudioRecordingDeviceInfo
Retrieves the audio capture device information associated with the device ID and device name.
Future<MediaDeviceInfo?> getAudioRecordingDeviceInfo()
Returns
A MediaDeviceInfo class that contains the device ID and device name of all the audio recording devices.
startAudioDeviceLoopbackTest
Starts an audio device loopback test.
Future<void> startAudioDeviceLoopbackTest(int indicationInterval)
This method tests whether the local audio capturing device and playback device work properly. After calling this method, the audio capturing device samples the local audio, and then the audio playback device plays the sampled audio.
-
Two
audioVolumeIndication
callbacks and two
audioDeviceTestVolumeIndication
callbacks when you call this method before joining the
channel, with the following values:
-
uid = 0
andvolume
in one audioVolumeIndication callback;uid = 1
andvolume
in the other audioVolumeIndication callback. -
volumeType = AudioTestRecordingVolume(0)
andvolume
in one audioDeviceTestVolumeIndication callback;volumeType = AudioTestPlaybackVolume(1)
andvolume
in the other audioDeviceTestVolumeIndication callback.
-
-
Two
audioDeviceTestVolumeIndication
callbacks when you call this method after joining a
channel, with the following values:
-
volumeType = AudioTestRecordingVolume(0)
andvolume
in one callback; -
volumeType = AudioTestPlaybackVolume(1)
andvolume
in the other one.
-
-
When you call this method after joining a channel, ensure
the audio capturing device is on (
enableLocalAudio
is set as
true
); otherwise, the method call fails, and the SDK triggers the error callback withERR_ADM_START_RECORDING(1012)
. - Calling this method after joining a channel tests the audio capturing device that the SDK is using.
- This method tests local audio devices and does not report the network conditions.
- After calling startRecordingDeviceTest, you must call stopAudioDeviceLoopbackTest to stop the test.
Parameters
- indicationInterval
-
The time interval (ms) at which the SDK triggers the audioVolumeIndication or audioDeviceTestVolumeIndication callback. Agora recommends a setting greater than 200 ms. This value must not be less than 10 ms; otherwise, you can not receive these callbacks.
stopAudioDeviceLoopbackTest
Stops the audio device loopback test.
Future<void> stopAudioDeviceLoopbackTest()
- Ensure that you call this method before joining a channel.
- Ensure that you call this method to stop the loopback test after calling the startAudioDeviceLoopbackTest method.
setAudioPlaybackDeviceVolume
Sets the volume of the audio playback device.
Future<void> setAudioPlaybackDeviceVolume(int volume)
Parameters
- volume
- The volume of the audio playback device. The value ranges between 0 (lowest volume) and 255 (highest volume).
getAudioPlaybackDeviceVolume
Retrieves the volume of the audio playback device.
Future<int?> getAudioPlaybackDeviceVolume()
Returns
The volume of the audio playback device. The value ranges between 0 (lowest volume) and 255 (highest volume).
setAudioRecordingDeviceVolume
Sets the volume of the audio capture device.
Future<void> setAudioRecordingDeviceVolume(int volume)
Parameters
- volume
- The volume of the audio recording device. The value ranges between 0 (lowest volume) and 255 (highest volume).
getAudioRecordingDeviceVolume
Retrieves the volume of the audio recording device.
Future<int?> getAudioRecordingDeviceVolume()
Returns
The volume of the audio recording device. The value ranges between 0 (lowest volume) and 255 (highest volume).
setAudioPlaybackDeviceMute
Mutes the audio playback device.
Future<void> setAudioPlaybackDeviceMute(bool mute)
Parameters
- mute
-
Whether to mute the audio playback device:
-
true
: Mute the audio playback device. -
false
: Unmute the audio playback device.
-
getAudioPlaybackDeviceMute
Retrieves whether the audio playback device is muted.
Future<bool?> getAudioPlaybackDeviceMute()
Returns
-
true
: The audio playback device is muted. -
false
: The audio playback device is unmuted.
setAudioRecordingDeviceMute
Sets the mute status of the audio capture device.
Future<void> setAudioRecordingDeviceMute(bool mute)
Parameters
- mute
-
Whether to mute the audio capture device:
-
true
: Mute the audio capture device. -
false
: Unmute the audio capture device.
-
getAudioRecordingDeviceMute
Gets the microphone's mute status.
Future<bool?> getAudioRecordingDeviceMute()
Returns
-
true
: The microphone is muted. -
false
: The microphone is unmuted.
enumerateVideoDevices
Enumerates the video devices.
Future<List<MediaDeviceInfo>> enumerateVideoDevices()
Returns
- Success: Returns a MediaDeviceInfo that contains all the video devices.
- Failure: null.
followSystemPlaybackDevice
Sets the audio playback device used by the SDK to follow the system default audio playback device.
Future<void> followSystemPlaybackDevice(bool enable);
Return values
- enable
-
Whether to follow the system default audio playback device:
- true: Follow. The SDK immediately switches the audio playback device when the system default audio playback device changes.
- false: Do not follow. The SDK switches the audio playback device to the system default audio playback device only when the currently used audio playback device is disconnected.
followSystemRecordingDevice
Sets the audio recording device used by the SDK to follow the system default audio recording device.
Future<void> followSystemRecordingDevice(bool enable);
- enable
-
Whether to follow the system default audio recording device:
- true: Follow. The SDK immediately switches the audio recording device when the system default audio recording device changes.
- false: Do not follow. The SDK switches the audio recording device to the system default audio recording device only when the currently used audio recording device is disconnected.
setVideoDevice
Specifies the video capture device with the device ID.
Future<void> setVideoDevice(String deviceId)
Parameters
- deviceId
-
The device ID. You can get the device ID by calling enumerateVideoDevices.
getVideoDevice
Retrieves the current video capture device.
Future<String?> getVideoDevice()
Returns
The video capture device.