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 CameraMethods = {
  /** Takes a picture with the current flash; the view must be ready. */
  takePicture(options?: PictureOptions): Promise<CameraPicture>;
  /**
   * Starts recording, in `video` mode. Resolves with the video once the
   * recording ends: `stopRecording`, `maxDuration`, the app leaving the
   * foreground, or the view unmounting.
   */
  startRecording(options?: RecordingOptions): Promise<CameraRecording>;
  /** Ends the recording, and resolves with the same video `startRecording` does. */
  stopRecording(): Promise<CameraRecording>;
  /** Freezes the preview and stops the camera, keeping the view. */
  pausePreview(): Promise<void>;
  resumePreview(): Promise<void>;
};

Members 5

NameTypeRequiredDescription
takePicture(options?: PictureOptions) => Promise<CameraPicture>YesTakes a picture with the current flash; the view must be ready.
startRecording(options?: RecordingOptions) => Promise<CameraRecording>YesStarts 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>YesEnds the recording, and resolves with the same video startRecording does.
pausePreview() => Promise<void>YesFreezes the preview and stops the camera, keeping the view.
resumePreview() => Promise<void>Yes—
takePicture — method signatures

Signatures

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

Parameters

NameTypeRequiredDescription
optionsSpecPictureOptionsNo—

Returns

Promise<SpecCameraPicture>

startRecording — method signatures

Signatures

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

Parameters

NameTypeRequiredDescription
optionsSpecRecordingOptionsNo—

Returns

Promise<SpecCameraRecording>

stopRecording — method signatures

Signatures

ts
(): Promise<CameraRecording>

Parameters

No parameters.

Returns

Promise<SpecCameraRecording>

pausePreview — method signatures

Signatures

ts
(): Promise<void>

Parameters

No parameters.

Returns

Promise<void>

resumePreview — method signatures

Signatures

ts
(): Promise<void>

Parameters

No parameters.

Returns

Promise<void>

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