MediaRecorder
Used for recording audio and video on the client.
- The audio captured by the local microphone and encoded in AAC format.
- The video captured by the local camera and encoded by the SDK.
getMediaRecorder
Gets the MediaRecorder object.
static MediaRecorder getMediaRecorder(RtcEngine engine, {MediaRecorderObserver? callback})
Parameters
- engine
- The RtcEngine object.
- callback
- The MediaRecorderObserver object.
Returns
The MediaRecorder object.
startRecording
Starts recording the local audio and video.
Future<void> startRecording(MediaRecorderConfiguration config);
After successfully getting the object, you can all this method to enable the recoridng of the local audio and video.
- The audio captured by the local microphone and encoded in AAC format.
- The video captured by the local camera and encoded by the SDK.
The SDK can generate a recording file only when it detects the recordable audio and video streams; when there are no audio and video streams to be recorded or the audio and video streams are interrupted for more than five seconds, the SDK stops recording and triggers the onRecorderStateChanged(Error, NoStream) callback.
Parameters
- config
- The recording configuration. See MediaRecorderConfiguration.
Returns
- 0(ERR_OK): Success.
-
< 0: Failure.
-
-2(ERR_INVALID_ARGUMANT)
: The parameter is invalid. Ensure the following:- The specified path of the recording file exists and is writable.
- The specified format of the recording file is supported.
- The maximum recording duration is correctly set.
-
-4(ERR_NOT_SUPPORTED)
: RtcEngine does not support the request due to one of the following reasons:- The recording is ongoing.
- The recording stops because an error occurs.
-
-7(ERR_NOT_INITIALIZED)
: This method is called before the initialization of RtcEngine.
-
stopRecording
Stops recording the local audio and video
Future<void> stopRecording();
Returns
- 0(ERR_OK): Success.
-
< 0: Failure:
-
-7(ERR_NOT_INITIALIZED)
: This method is called before the initialization of RtcEngine.
-
releaseRecorder
Releases the MediaRecorder object.
Future<void> releaseRecorder();
This method releases the RtcEngine object and all the other resources used by MediaRecorder. After calling this method, if you want to enable the recording again, you must call getMediaRecorder to get the MediaRecorder first.