Utilisation

Pause and resume a camera preview.

tsx
// 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

ts
export type CameraHandle = NativeViewHandle<CameraMethods>;

Membres 14

NomTypeRequisDescription
idlecture seulestringOui—
parentlecture seuleElementHandleOui—
childrenlecture seuleElementHandle[]Oui—
focus() => voidOui—
blur() => voidOui—
setProperty<K extends keyof ElementProperties>(key: K, value: ElementProperties[K] | null) => voidOuiSets 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;}) => voidOui—
removeEventListener(type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean;}) => voidOui—
dispatchEvent(event: { type: string; bubbles?: boolean; cancelable?: boolean;}) => booleanOuiSends 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>OuiTakes a picture with the current flash; the view must be ready.
startRecording(options?: RecordingOptions) => Promise<CameraRecording>OuiStarts 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>OuiEnds the recording, and resolves with the same video startRecording does.
pausePreview() => Promise<void>OuiFreezes the preview and stops the camera, keeping the view.
resumePreview() => Promise<void>Oui—
focus — signatures de méthode

Signatures

ts
(): void

Paramètres

Aucun paramètre.

Retourne

void

blur — signatures de méthode

Signatures

ts
(): void

Paramètres

Aucun paramètre.

Retourne

void

setProperty — signatures de méthode

Signatures

ts
<K extends keyof ElementProperties>(key: K, value: ElementProperties[K] | null): void

Paramètres de type

NomContraintePar défaut
Kkeyof ElementProperties—

Paramètres

NomTypeRequisDescription
keyKOui—
valueElementProperties[K]Oui—

Retourne

void

addEventListener — signatures de méthode

Signatures

ts
(type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean; once?: boolean; signal?: AbortSignal; }): void

Paramètres

NomTypeRequisDescription
typestringOui—
fn(e: KuitoNativeEvent) => voidOui—
optionsboolean | { capture?: boolean; once?: boolean; signal?: AbortSignal;}Non—

Retourne

void

removeEventListener — signatures de méthode

Signatures

ts
(type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean; }): void

Paramètres

NomTypeRequisDescription
typestringOui—
fn(e: KuitoNativeEvent) => voidOui—
optionsboolean | { capture?: boolean;}Non—

Retourne

void

dispatchEvent — signatures de méthode

Signatures

ts
(event: { type: string; bubbles?: boolean; cancelable?: boolean; }): boolean

Paramètres

NomTypeRequisDescription
event{ type: string; bubbles?: boolean; cancelable?: boolean;}Oui—

Retourne

boolean

takePicture — signatures de méthode

Signatures

ts
(options?: PictureOptions): Promise<CameraPicture>

Paramètres

NomTypeRequisDescription
optionsSpecPictureOptionsNon—

Retourne

Promise<SpecCameraPicture>

startRecording — signatures de méthode

Signatures

ts
(options?: RecordingOptions): Promise<CameraRecording>

Paramètres

NomTypeRequisDescription
optionsSpecRecordingOptionsNon—

Retourne

Promise<SpecCameraRecording>

stopRecording — signatures de méthode

Signatures

ts
(): Promise<CameraRecording>

Paramètres

Aucun paramètre.

Retourne

Promise<SpecCameraRecording>

pausePreview — signatures de méthode

Signatures

ts
(): Promise<void>

Paramètres

Aucun paramètre.

Retourne

Promise<void>

resumePreview — signatures de méthode

Signatures

ts
(): 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.