CameraMethods
What an app can ask a mounted Camera to do through its ref: take pictures, record video and pause the preview.
Usage
Pause and resume a camera preview.
This type is used by Camera
// 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 CameraMethods = {
/** Takes a picture with the current flash; the view must be ready. */
takePicture(options?: PictureOptions): Promise<CameraPicture>;
/**
* Starts recording, in `video` mode. Resolves with the video once the
* recording ends: `stopRecording`, `maxDuration`, the app leaving the
* foreground, or the view unmounting.
*/
startRecording(options?: RecordingOptions): Promise<CameraRecording>;
/** Ends the recording, and resolves with the same video `startRecording` does. */
stopRecording(): Promise<CameraRecording>;
/** Freezes the preview and stops the camera, keeping the view. */
pausePreview(): Promise<void>;
resumePreview(): Promise<void>;
};Members 5
| Name | Type | Required | Description |
|---|---|---|---|
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 | — |
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.