CameraState

class CameraState(context: Context)

A state object that can be hoisted to control camera, take picture or record video.

To be created use rememberCameraState.

Constructors

Link copied to clipboard
constructor(context: Context)

Properties

Link copied to clipboard

Main controller from CameraX. useful in cases that haven't been release some feature yet.

Link copied to clipboard

Verify if camera has flash or not.

Link copied to clipboard
Link copied to clipboard

Check if compensation exposure is supported.

Link copied to clipboard

Check if focus on tap supported

Link copied to clipboard

Check if image analysis is supported by camera hardware level.

Link copied to clipboard

Check if camera state is initialized or not.

Link copied to clipboard

Return true if it's recording.

Link copied to clipboard

Check if camera is streaming or not.

Link copied to clipboard

Return if video is supported.

Link copied to clipboard

Check if zoom is supported.

Link copied to clipboard

Get max exposure from camera.

Link copied to clipboard

Get max zoom from camera.

Link copied to clipboard

Get min exposure from camera.

Link copied to clipboard

Get min zoom from camera.

Functions

Link copied to clipboard

Set effects on camera

Link copied to clipboard
fun hasCamera(cameraSelector: CamSelector): Boolean

Return if has camera selector or not, camera must be initialized, otherwise result is false.

Link copied to clipboard
@RequiresApi(value = 23)
fun muteRecording(muted: Boolean)
Link copied to clipboard
@RequiresApi(value = 23)
fun pauseRecording()
Link copied to clipboard
fun CameraState.rememberFlashMode(initialFlashMode: FlashMode = FlashMode.Off, useSaver: Boolean = true): MutableState<FlashMode>

Flash mode's State to CameraPreview Composable.

Link copied to clipboard
fun CameraState.rememberImageAnalyzer(imageAnalysisBackpressureStrategy: ImageAnalysisBackpressureStrategy = ImageAnalysisBackpressureStrategy.KeepOnlyLatest, imageAnalysisTargetSize: ImageTargetSize? = ImageTargetSize(this.imageAnalysisTargetSize), imageAnalysisImageQueueDepth: Int = this.imageAnalysisImageQueueDepth, analyze: ImageAnalysis.Analyzer): ImageAnalyzer

Create instance remember of ImageAnalyzer.

Link copied to clipboard
fun CameraState.rememberTorch(initialTorch: Boolean = false, useSaver: Boolean = true): MutableState<Boolean>

Torch's State to CameraPreview Composable.

Link copied to clipboard
@RequiresApi(value = 23)
fun resumeRecording()
Link copied to clipboard
fun setEffects(effects: Set<CameraEffect>)

Set effects on camera

Link copied to clipboard
@RequiresApi(value = 26)
@RequiresPermission(value = "android.permission.RECORD_AUDIO")
fun startRecording(fileDescriptorOutputOptions: FileDescriptorOutputOptions, audioConfig: AudioConfig = AudioConfig.create(true), onResult: (VideoCaptureResult) -> Unit)
@RequiresApi(value = 24)
@RequiresPermission(value = "android.permission.RECORD_AUDIO")
fun startRecording(fileOutputOptions: FileOutputOptions, audioConfig: AudioConfig = AudioConfig.create(true), onResult: (VideoCaptureResult) -> Unit)
@RequiresApi(value = 24)
@RequiresPermission(value = "android.permission.RECORD_AUDIO")
fun startRecording(mediaStoreOutputOptions: MediaStoreOutputOptions, audioConfig: AudioConfig = AudioConfig.create(true), onResult: (VideoCaptureResult) -> Unit)

Start recording camera.

Link copied to clipboard
@RequiresApi(value = 23)
fun stopRecording()

Stop recording camera.

Link copied to clipboard
fun takePicture(outputFileOptions: ImageCapture.OutputFileOptions, onResult: (ImageCaptureResult) -> Unit)
fun takePicture(file: File, onResult: (ImageCaptureResult) -> Unit)
fun takePicture(contentValues: ContentValues, saveCollection: Uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI, onResult: (ImageCaptureResult) -> Unit)

Take a picture with the camera.

Link copied to clipboard
suspend fun CameraState.takePicture(outputFileOptions: ImageCapture.OutputFileOptions): Uri?

Transform takePicture output files options to suspend function

suspend fun CameraState.takePicture(file: File): Uri?

Transform takePicture file to suspend function

suspend fun CameraState.takePicture(contentValues: ContentValues, saveCollection: Uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI): Uri?

Transform takePicture content values to suspend function

Link copied to clipboard
@RequiresApi(value = 26)
@RequiresPermission(value = "android.permission.RECORD_AUDIO")
fun toggleRecording(fileDescriptorOutputOptions: FileDescriptorOutputOptions, audioConfig: AudioConfig = AudioConfig.create(true), onResult: (VideoCaptureResult) -> Unit)
@RequiresApi(value = 24)
@RequiresPermission(value = "android.permission.RECORD_AUDIO")
fun toggleRecording(fileOutputOptions: FileOutputOptions, audioConfig: AudioConfig = AudioConfig.create(true), onResult: (VideoCaptureResult) -> Unit)
@RequiresApi(value = 24)
@RequiresPermission(value = "android.permission.RECORD_AUDIO")
fun toggleRecording(mediaStoreOutputOptions: MediaStoreOutputOptions, audioConfig: AudioConfig = AudioConfig.create(true), onResult: (VideoCaptureResult) -> Unit)

Toggle recording camera.

Link copied to clipboard
@RequiresApi(value = 26)
@RequiresPermission(value = "android.permission.RECORD_AUDIO")
suspend fun CameraState.toggleRecording(fileDescriptorOutputOptions: FileDescriptorOutputOptions, audioConfig: AudioConfig = AudioConfig.create(true)): Uri?

Transform toggle recording output files options to suspend function

@RequiresApi(value = 26)
@RequiresPermission(value = "android.permission.RECORD_AUDIO")
suspend fun CameraState.toggleRecording(fileOutputOptions: FileOutputOptions, audioConfig: AudioConfig = AudioConfig.create(true)): Uri?

Transform toggle recording file to suspend function

@RequiresApi(value = 24)
@RequiresPermission(value = "android.permission.RECORD_AUDIO")
suspend fun CameraState.toggleRecording(mediaStoreOutputOptions: MediaStoreOutputOptions, audioConfig: AudioConfig = AudioConfig.create(true)): Uri?

Transform toggle recording content values options to suspend function