Utilisation

Pause and resume a camera preview.

Ce type est utilisé par Camera

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 CameraProps = {
  /** `back` by default. */
  facing?: CameraFacing;
  /** `off` by default. */
  flash?: CameraFlash;
  /** Keeps the light on while the preview runs. */
  torch?: boolean;
  /** From 0 (none) to 1 (the most the camera can), linearly. 0 by default. */
  zoom?: number;
  /** `picture` by default. Record videos in `video`. */
  mode?: CameraMode;
  /** Records videos without sound, and without asking for the microphone. */
  mute?: boolean;
  /** Scans for these codes while the preview runs. */
  barcodes?: BarcodeType[];
  /** The preview is running: the camera can take pictures and record. */
  onReady?: (event: CameraReadyEvent) => void;
  onError?: (event: CameraErrorEvent) => void;
  /** Each time a code of `barcodes` comes into view. */
  onBarcode?: (event: BarcodeEvent) => void;
};

Membres 10

NomTypeRequisDescription
facingCameraFacingNonback by default.
flashCameraFlashNonoff by default.
torchbooleanNonKeeps the light on while the preview runs.
zoomnumberNonFrom 0 (none) to 1 (the most the camera can), linearly. 0 by default.
modeCameraModeNonpicture by default. Record videos in video.
mutebooleanNonRecords videos without sound, and without asking for the microphone.
barcodesBarcodeType[]NonScans for these codes while the preview runs.
onReady(event: CameraReadyEvent) => voidNonThe preview is running: the camera can take pictures and record.
onError(event: CameraErrorEvent) => voidNon—
onBarcode(event: BarcodeEvent) => voidNonEach time a code of barcodes comes into view.
onReady — signatures de méthode

Signatures

ts
(event: CameraReadyEvent): void

Paramètres

NomTypeRequisDescription
eventCameraReadyEventOui—

Retourne

void

onError — signatures de méthode

Signatures

ts
(event: CameraErrorEvent): void

Paramètres

NomTypeRequisDescription
eventCameraErrorEventOui—

Retourne

void

onBarcode — signatures de méthode

Signatures

ts
(event: BarcodeEvent): void

Paramètres

NomTypeRequisDescription
eventBarcodeEventOui—

Retourne

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.