Utilização

Pause and resume a camera preview.

Este tipo é usado por 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>
    </>
  );
}

Declaração do tipo

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;
};

Membros 10

NomeTipoObrigatórioDescrição
facingCameraFacingNãoback by default.
flashCameraFlashNãooff by default.
torchbooleanNãoKeeps the light on while the preview runs.
zoomnumberNãoFrom 0 (none) to 1 (the most the camera can), linearly. 0 by default.
modeCameraModeNãopicture by default. Record videos in video.
mutebooleanNãoRecords videos without sound, and without asking for the microphone.
barcodesBarcodeType[]NãoScans for these codes while the preview runs.
onReady(event: CameraReadyEvent) => voidNãoThe preview is running: the camera can take pictures and record.
onError(event: CameraErrorEvent) => voidNão—
onBarcode(event: BarcodeEvent) => voidNãoEach time a code of barcodes comes into view.
onReady — assinaturas de método

Assinaturas

ts
(event: CameraReadyEvent): void

Parâmetros

NomeTipoObrigatórioDescrição
eventCameraReadyEventSim—

Devolve

void

onError — assinaturas de método

Assinaturas

ts
(event: CameraErrorEvent): void

Parâmetros

NomeTipoObrigatórioDescrição
eventCameraErrorEventSim—

Devolve

void

onBarcode — assinaturas de método

Assinaturas

ts
(event: BarcodeEvent): void

Parâmetros

NomeTipoObrigatórioDescrição
eventBarcodeEventSim—

Devolve

void

Gerado a partir das declarações TypeScript públicas: assinaturas, props e predefinições vêm da fonte verificada, as descrições da sua JSDoc. Nenhuma predefinição é inventada.