CameraMethods
What an app can ask a mounted Camera to do through its ref: take pictures, record video and pause the preview.
Utilisation
Pause and resume a camera preview.
Ce type est utilisé par 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>
</>
);
}Déclaration du type
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>;
};Membres 5
| Nom | Type | Requis | Description |
|---|---|---|---|
takePicture | (options?: PictureOptions) => Promise<CameraPicture> | Oui | Takes a picture with the current flash; the view must be ready. |
startRecording | (options?: RecordingOptions) => Promise<CameraRecording> | Oui | 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> | Oui | Ends the recording, and resolves with the same video startRecording does. |
pausePreview | () => Promise<void> | Oui | Freezes the preview and stops the camera, keeping the view. |
resumePreview | () => Promise<void> | Oui | — |
takePicture — signatures de méthode
Signatures
(options?: PictureOptions): Promise<CameraPicture>Paramètres
| Nom | Type | Requis | Description |
|---|---|---|---|
options | SpecPictureOptions | Non | — |
Retourne
Promise<SpecCameraPicture>
startRecording — signatures de méthode
Signatures
(options?: RecordingOptions): Promise<CameraRecording>Paramètres
| Nom | Type | Requis | Description |
|---|---|---|---|
options | SpecRecordingOptions | Non | — |
Retourne
Promise<SpecCameraRecording>
stopRecording — signatures de méthode
Signatures
(): Promise<CameraRecording>Paramètres
Aucun paramètre.
Retourne
Promise<SpecCameraRecording>
pausePreview — signatures de méthode
Signatures
(): Promise<void>Paramètres
Aucun paramètre.
Retourne
Promise<void>
resumePreview — signatures de méthode
Signatures
(): Promise<void>Paramètres
Aucun paramètre.
Retourne
Promise<void>
Généré depuis les déclarations TypeScript publiques : signatures, props et valeurs par défaut viennent de la source vérifiée, les descriptions de sa JSDoc. Aucune valeur par défaut n'est inventée.