Verwendung

Pause and resume a camera preview.

Dieser Typ wird verwendet von 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>
    </>
  );
}

Typdeklaration

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

Mitglieder 10

NameTypErforderlichBeschreibung
facingCameraFacingNeinback by default.
flashCameraFlashNeinoff by default.
torchbooleanNeinKeeps the light on while the preview runs.
zoomnumberNeinFrom 0 (none) to 1 (the most the camera can), linearly. 0 by default.
modeCameraModeNeinpicture by default. Record videos in video.
mutebooleanNeinRecords videos without sound, and without asking for the microphone.
barcodesBarcodeType[]NeinScans for these codes while the preview runs.
onReady(event: CameraReadyEvent) => voidNeinThe preview is running: the camera can take pictures and record.
onError(event: CameraErrorEvent) => voidNein—
onBarcode(event: BarcodeEvent) => voidNeinEach time a code of barcodes comes into view.
onReady — Methodensignaturen

Signaturen

ts
(event: CameraReadyEvent): void

Parameter

NameTypErforderlichBeschreibung
eventCameraReadyEventJa—

Rückgabe

void

onError — Methodensignaturen

Signaturen

ts
(event: CameraErrorEvent): void

Parameter

NameTypErforderlichBeschreibung
eventCameraErrorEventJa—

Rückgabe

void

onBarcode — Methodensignaturen

Signaturen

ts
(event: BarcodeEvent): void

Parameter

NameTypErforderlichBeschreibung
eventBarcodeEventJa—

Rückgabe

void

Generiert aus den öffentlichen TypeScript-Deklarationen: Signaturen, Props und Standardwerte stammen aus der geprüften Quelle, Beschreibungen aus deren JSDoc. Kein Standardwert ist erfunden.