Code
Camposer – Camera Library for Android Jetpack Compose

Tired to use a camera in Jetpack Compose with interoperability? Then Camposer was made for you. A camera library totally in Jetpack Compose which supports taking photos, recording videos, flash modes, zoom ratio, and among others!
How it works
To add CameraPreview composable, just use the example below:
val cameraState = rememberCameraState()
var camSelector = rememberCamSelector(CamSelector.Back)
CameraPreview(
cameraState = cameraState,
camSelector = camSelector,
) {
// Camera Preview UI
}
Take picture
// Using content values
cameraState.takePicture(contentValues, mediaURI) { result ->
/* ... */
}
// Using files
cameraState.takePicture(file) { result -> /* ... */ }
Start recording
// Using content values
cameraState.startRecording()
cameraState.stopRecording(contentValues, mediaURI) { result ->
/* ... */
}
// Using file
cameraState.startRecording()
cameraState.stopRecording(file) { result -> /* ... */ }
// Using content values + toggle
cameraState.toggleRecording(contentValues, mediaURI) { result ->
/* ... */
}
// Using files + toggle
cameraState.toggleRecording(file) { result -> /* ... */ }
Switch cameras
To switch cameras, you have to add camSelector
to your CameraPreview
composable, as shown previously, after implementation, just need to change its state.
// Use front camera
camSelector = CamSelector.Front
// Use back camera
camSelector = CamSelector.Back
// Inverse camera selector
camSelector = camSelector.inverse
Other configurations
If you want to use other configurations, you can see our wiki.
Setup
- Add dependency to your
build.gradle
implementation 'io.github.ujizin:camposer:0.1.0'
- Sync your project
- Have a
fun code()
!
