The entry point for the recorder SDK is the
This interface provides functions to:
- start and stop the recording
- control the camera through
- configure the upload
- preview the recorded video
- build a responsive UI to show controls to the user.
The recorder will also forward all relevant events to subscribers that were registered with the
addListener* functions. We recommend listening at least to the result and error event:
We provide different implementations that can be used within your app depending on your needs, but all of them share the same API surface described below. All of them will also automatically request the appropriate permissions: camera, microphone and, in some cases, storage.
Note: if you use the default controls, the user will be able to control the recorder through the user interface, so there's no need to interact directly with these functions.
The recorder is able to record multiple clips together in a single file. This means that recording can be paused and resumed as many times as you want. To start recording:
This will soon move the
To pause recording:
This will bring back
RecorderState.IDLE. At this point, the video is not finalized,
and you have different options:
- resume recording, with
- confirm the video, with
- discard the video, with
- enter or exit preview mode
The recorder can go through multiple
pause() calls and the new video will
just be appended to the existing content. You can also change camera sensor and settings in between.
As you record clips with
pause(), the recorder will expose information about
the recorded data with
When multiple clips are recorded (through multiple start / pause cycles), we offer the option to seamlessly remove the last clip - as many modern apps do - without losing the previous segments.
If the recorder only has 1 clip, calling
removeLastClip has the same effect of canceling the video.
To discard the recorded data (assuming it was not confirmed yet), simply call
reset(). This will
move the recorder to its original state, with no pending record and zero clips:
To confirm the recorded data (be it 1 or multiple clips), simply call
confirm(). This tells
the recorder that you are not planning to write anything else to this file.
After this call, you should soon receive a complete
Record in the
onResult() listener callback.
The record will contain several properties, most importantly an
uri pointing to the resulting file.
As said, each
pause() cycle appends a new clip to the
clips list, and the final
will contain a video that is made of all the clips, merged together. On top of this, it is possible
to have a separate video file for each clip:
When this option is enabled, the clips returned by
Recorder.clips (and, after confirmation, by
will include a non-null uri that you can retreive with
Clips.uri. This media file only includes that video
segment. This is very useful if you want to process all clips later, for example pass them to our Editor SDK.
The recorder has an option to stop recording automatically after a certain duration has been
reached. This duration can be set through
recorder.maxDuration in milliseconds:
You have the option to import videos from the gallery using the
In both cases, the recorder will enter preview mode to preview the video.
You can configure both audio and video encoding parameters using the
and passing them to the recorder. Since the encoders available on-device might not support all configuration,
the recorder class accepts a list of options instead of a single value.
The recorder will try each option and, if not supported, try with the next one.