Skip to main content
Version: Android SDK v1.3.0

State & Events

Every implementation keeps its internal state and offers a way to register observer objects to listen to important events.

Recorder state

The recorder state can be retrieved with recorder.state and, similar to our player component, matches one of the constants in the class:

RecorderState.BusyRecorder is busy in some operation or transitioning from one state to another.
RecorderState.IdleRecorder is showing the camera preview, not recording.
RecorderState.RecordingRecorder is recording the camera preview.
RecorderState.PreviewRecorder is in preview mode, previewing a previously recorded video.

Recorder events

All Recorder events are dispatched to a that was previously registered using addObserver or similar function.

recorder.observeIn(lifecycle, observer) // start listening, stops automatically
recorder.observeIn(coroutineJob, observer) // start listening, stops automatically

recorder.addObserver(observer) // start listening, remember to remove later
recorder.removeObserver(observer) // stop listening

Observers are very important to be up-to-date about the recorder state, handle errors and create a responsive UI. We describe the observer interface as comments in the interface description below.

recorder.addObserver(object : Recorder.Observer {
override fun onResult(record: Record) {
// Called after confirming the record.

override fun onError(error: VideoKitException) {
// Something went wrong! Handle the error.

override fun onStateChanged(state: RecorderState) {
// State changed!

override fun onRecordingChanged(recording: Recording?) {
// If recording != null, we now have a pending recording.
// This happens after the first clip is started.

override fun onDurationChanged(duration: Long) {
// Duration has changed, as recording progresses.


For kotlinx.coroutines users, note that all the reactive properties that are dispatched to the observers are also available as a Flow and StateFlow.

.onEach { /* state changed */ }

.onEach { /* something went wrong */ }

// And more