Usage

Pause and resume a camera preview.

This type is used by 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>
    </>
  );
}

Type declaration

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

Members 10

NameTypeRequiredDescription
facingCameraFacingNoback by default.
flashCameraFlashNooff by default.
torchbooleanNoKeeps the light on while the preview runs.
zoomnumberNoFrom 0 (none) to 1 (the most the camera can), linearly. 0 by default.
modeCameraModeNopicture by default. Record videos in video.
mutebooleanNoRecords videos without sound, and without asking for the microphone.
barcodesBarcodeType[]NoScans for these codes while the preview runs.
onReady(event: CameraReadyEvent) => voidNoThe preview is running: the camera can take pictures and record.
onError(event: CameraErrorEvent) => voidNo—
onBarcode(event: BarcodeEvent) => voidNoEach time a code of barcodes comes into view.
onReady — method signatures

Signatures

ts
(event: CameraReadyEvent): void

Parameters

NameTypeRequiredDescription
eventCameraReadyEventYes—

Returns

void

onError — method signatures

Signatures

ts
(event: CameraErrorEvent): void

Parameters

NameTypeRequiredDescription
eventCameraErrorEventYes—

Returns

void

onBarcode — method signatures

Signatures

ts
(event: BarcodeEvent): void

Parameters

NameTypeRequiredDescription
eventBarcodeEventYes—

Returns

void

Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.