Skip to content

Recording video

Lucas Yuji Yoshimine edited this page Feb 25, 2026 · 2 revisions

Recording Video

⚠️ WARNING

This documentation applies to versions below 1.0.0 and is DEPRECATED. If you're using version 1.0.0 or later, please refer to the updated documentation.

there's a little bit of difference between recording video and taking pictures with Camposer, but the methods to save are very similar with CameraState:

All of these options use the method CameraState.startRecording or CameraState.toggleRecording, which has the last parameter: the callback with video capture result, and if successful, it contains the saved URI.

addition: if you're using CameraState.startRecording, to stop video use CameraState.stopRecording. With CameraState.toggleRecording just call twice.

Here is an example using the file:

val cameraState = rememberCameraState()
val isRecording = rememberUpdateState(cameraState.isRecording) // check if it's recording

val context = LocalContext.current
CameraPreview(
  cameraState = cameraState,
) {
  Box(
    onClick = { 
      cameraState.toggleRecording(file) { result -> 
        if (result is VideoCaptureResult.Success) { // result.savedUri might be useful to you
          Toast.makeText(context, "Success!", Toast.LENGTH_LONG).show()
        }
      } 
    }
  ) {
    Text(text = "Record: $isRecording")
  }
}

There's also support to suspend functions! Using suspend functions TakePicture it's return savedUri or throw throwable, so be careful when used it.


CameraState.isRecording

Check if it's recording or not, can be used with rememberUpdateState or other states...


If you want to see some example using with androidx ViewModel, check out the Sample Project

Clone this wiki locally