CameraRef
A Camera's ref that also holds its state: ready while the preview
runs and the camera can take pictures and record, and the last error.
Called while a component sets up, which owns it, like ref().
Usage
Configure video capture.
This type is used by cameraRef
// Configure video capture.
import { Button, Camera, cameraRef, type RecordingOptions } from 'kuito';
// A clip stops on its own after 15 seconds.
const clip: RecordingOptions = { maxDuration: 15 };
function Clip() {
const camera = cameraRef();
const record = async () => {
const video = await camera.current?.startRecording(clip);
console.log(video?.uri, video?.duration);
};
return (
<>
<Camera ref={camera} mode="video" flex={1} />
<Button onPress={record}>Record</Button>
</>
);
}Type declaration
export type CameraRef = ElementRef<CameraHandle> & {
readonly ready: ReadonlySignal<boolean>;
readonly error: ReadonlySignal<{ code: string; message: string } | null>;
};Members 3
| Name | Type | Required | Description |
|---|---|---|---|
current | CameraHandle | Yes | — |
readyreadonly | ReadonlySignal<boolean> | Yes | — |
errorreadonly | ReadonlySignal<{ code: string; message: string;}> | Yes | — |
Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.