startAudioRecording method Null safety
Starts an audio recording from a client.
The method records the mixing audio from all room members in te room, and store the recording file locally. /// The onAudioRecording callback is triggered when recording starts or ends.
If you specify a type of audio quality, the recording file is saved in different formats.
- A WAV file is large with a high quality
- An AAC file is small with a low quality.
Call this method after you join a room. A client can only run one recording task. If you repeatedly call the startAudioRecording method, the current recording task stops and a new recording task starts. If the current user leaves the room, audio recording automatically stops. You can call the stopAudioRecording method to manually stop recording during calls.
filePath specifies the absolute path where the recording file is stored. The file name and format are required. For example, sdcard/xxx/audio.aac. Make sure that the path is valid and has the write permissions. Only WAV or AAC files are supported.
sampleRate specifies the recording sample rate in Hz. Valid values: 16000,32000, 44100, and 48000. The default value is 32000.
quality specifies the audio quality. The parameter is valid only if the recording file is in AAC format. For more information, see NERtcAudioRecordingQuality.
Implementation
Future<int> startAudioRecording(
String filePath, int sampleRate, int quality) async {
IntValue reply = await _api.startAudioRecording(StartAudioRecordingRequest()
..filePath = filePath
..sampleRate = sampleRate
..quality = quality);
return reply.value ?? -1;
}