Audio Device Management

getAudioDeviceInfo

Gets audio device information.

public abstract DeviceInfo getAudioDeviceInfo();
Note: You can call this method before or after joining a channel.

Return Values

If the method call succeeds, returns a DeviceInfo object. If the method call fails, returns null.

startPlaybackDeviceTest

Starts local audio playback device test.

public abstract int startPlaybackDeviceTest(String audioFileName);

After calling this method, the SDK plays the specified audio file. If you can hear the audio, it indicates that the playback device is working properly. After the call, the SDK triggers the onAudioVolumeIndication callback every 100 ms to report the volume information of the playback device with uid 1. The difference between this method and startEchoTest is that startPlaybackDeviceTest only tests the local audio playback device, while startEchoTest tests both audio/video devices and network conditions.

Note: Call this method before joining a channel. After the test is complete, call stopPlaybackDeviceTest before joining the channel to stop the test.

Parameters

audioFileName
Path to the audio file, a UTF-8 encoded string. Supported formats: wav, mp3, m4a, and aac. Supported sample rates: 8000, 16000, 32000, 44100, and 48000 Hz.

Return Values

  • 0: Success.
  • < 0: Failure.

startRecordingDeviceTest

Starts the audio recording device test.

public abstract int startRecordingDeviceTest(int indicationInterval);

After calling this method, the SDK triggers the onAudioVolumeIndication callback at the set interval, reporting uid = 0 and the volume of the recording device. This differs from startEchoTest in that startRecordingDeviceTest only checks the local recording device, while startEchoTest also checks video devices and network.

Note: Call this method before joining a channel. After the test, call stopRecordingDeviceTest before joining a channel to stop the test.

Parameters

indicationInterval
Interval (ms) for triggering onAudioVolumeIndication. Must be greater than 10, otherwise the callback won't be triggered and the SDK returns error -2. Recommended: 100.

Return Values

  • 0: Success.
  • < 0: Failure.
    • -2: Invalid parameter. Check parameter settings.

stopPlaybackDeviceTest

Stops audio playback device test.

public abstract int stopPlaybackDeviceTest();

You need to call this method after calling startPlaybackDeviceTest to stop the test.

Note: Call this method before joining a channel.

Return Values

  • 0: Success.
  • < 0: Failure.

stopRecordingDeviceTest

Stops the audio recording device test.

public abstract int stopRecordingDeviceTest();

You must call this method after calling startRecordingDeviceTest to stop the audio recording device test.

Note: Call this method before joining a channel.

Return Values

  • 0: Success.
  • < 0: Failure.