CameraHandle
What a Camera's ref holds: ref<CameraHandle>().
Usage
Pause and resume a camera preview.
// Pause and resume a camera preview.
import { Button, Camera, ref, type CameraHandle } from 'kuito';
function Scanner() {
// A plain ref holds the handle; cameraRef() adds ready and error signals.
const camera = ref<CameraHandle>();
return (
<>
<Camera ref={camera} flex={1} />
<Button onPress={() => void camera.current?.pausePreview()}>Pause</Button>
<Button onPress={() => void camera.current?.resumePreview()}>Resume</Button>
</>
);
}Type declaration
export type CameraHandle = NativeViewHandle<CameraMethods>;Members 14
| Name | Type | Required | Description |
|---|---|---|---|
idreadonly | string | Yes | — |
parentreadonly | ElementHandle | Yes | — |
childrenreadonly | ElementHandle[] | Yes | — |
focus | () => void | Yes | — |
blur | () => void | Yes | — |
setProperty | <K extends keyof ElementProperties>(key: K, value: ElementProperties[K] | null) => void | Yes | Sets a native prop on the view now, until its binding writes it again. |
addEventListener | (type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean; once?: boolean; signal?: AbortSignal;}) => void | Yes | — |
removeEventListener | (type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean;}) => void | Yes | — |
dispatchEvent | (event: { type: string; bubbles?: boolean; cancelable?: boolean;}) => boolean | Yes | Sends an event through the tree, capture to bubble, as a native one travels:
a KuitoCustomEvent, or any object with a type. False when a listener
called preventDefault() on a cancelable event. |
takePicture | (options?: PictureOptions) => Promise<CameraPicture> | Yes | Takes a picture with the current flash; the view must be ready. |
startRecording | (options?: RecordingOptions) => Promise<CameraRecording> | Yes | Starts recording, in video mode. Resolves with the video once the
recording ends: stopRecording, maxDuration, the app leaving the
foreground, or the view unmounting. |
stopRecording | () => Promise<CameraRecording> | Yes | Ends the recording, and resolves with the same video startRecording does. |
pausePreview | () => Promise<void> | Yes | Freezes the preview and stops the camera, keeping the view. |
resumePreview | () => Promise<void> | Yes | — |
focus — method signatures
Signatures
(): voidParameters
No parameters.
Returns
void
blur — method signatures
Signatures
(): voidParameters
No parameters.
Returns
void
setProperty — method signatures
Signatures
<K extends keyof ElementProperties>(key: K, value: ElementProperties[K] | null): voidType parameters
| Name | Constraint | Default |
|---|---|---|
K | keyof ElementProperties | — |
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
key | K | Yes | — |
value | ElementProperties[K] | Yes | — |
Returns
void
addEventListener — method signatures
Signatures
(type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean; once?: boolean; signal?: AbortSignal; }): voidParameters
| Name | Type | Required | Description |
|---|---|---|---|
type | string | Yes | — |
fn | (e: KuitoNativeEvent) => void | Yes | — |
options | boolean | { capture?: boolean; once?: boolean; signal?: AbortSignal;} | No | — |
Returns
void
removeEventListener — method signatures
Signatures
(type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean; }): voidParameters
| Name | Type | Required | Description |
|---|---|---|---|
type | string | Yes | — |
fn | (e: KuitoNativeEvent) => void | Yes | — |
options | boolean | { capture?: boolean;} | No | — |
Returns
void
dispatchEvent — method signatures
Signatures
(event: { type: string; bubbles?: boolean; cancelable?: boolean; }): booleanParameters
| Name | Type | Required | Description |
|---|---|---|---|
event | { type: string; bubbles?: boolean; cancelable?: boolean;} | Yes | — |
Returns
boolean
takePicture — method signatures
Signatures
(options?: PictureOptions): Promise<CameraPicture>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
options | SpecPictureOptions | No | — |
Returns
Promise<SpecCameraPicture>
startRecording — method signatures
Signatures
(options?: RecordingOptions): Promise<CameraRecording>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
options | SpecRecordingOptions | No | — |
Returns
Promise<SpecCameraRecording>
stopRecording — method signatures
Signatures
(): Promise<CameraRecording>Parameters
No parameters.
Returns
Promise<SpecCameraRecording>
pausePreview — method signatures
Signatures
(): Promise<void>Parameters
No parameters.
Returns
Promise<void>
resumePreview — method signatures
Signatures
(): Promise<void>Parameters
No parameters.
Returns
Promise<void>
Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.