Usage

Configure a component-owned voice recorder.

This type is used by audio.recorder

tsx
// Configure a component-owned voice recorder.
import { Button, audio, type RecordingFormat, type RecordingQuality } from 'kuito';

export function Memo() {
  const format: RecordingFormat = 'aac';
  const quality: RecordingQuality = 'high';
  const recorder = audio.recorder({ format, quality });
  return <Button onPress={() => void recorder.start().catch(console.error)}>Record</Button>;
}
// Declare microphone permission; finish the file with recorder.stop().

Type declaration

ts
export type AudioRecorder = {
  readonly id: number;
  readonly recording: ReadonlySignal<boolean>;
  /** Seconds recorded so far, moved by the UI thread while recording. */
  readonly time: Motion<number>;
  /** The input level in dBFS, -160 (silence) to 0, when `metering` is on. */
  readonly level: Motion<number>;
  readonly error: ReadonlySignal<string | null>;
  /** Starts a new file, asking for the microphone first, or resumes a paused one. */
  start(): Promise<void>;
  pause(): Promise<void>;
  /** Finishes the file and resolves its `file://` URI, in the cache directory. */
  stop(): Promise<Recording>;
};

Members 8

NameTypeRequiredDescription
idreadonlynumberYes—
recordingreadonlyReadonlySignal<boolean>Yes—
timereadonlyMotion<number>YesSeconds recorded so far, moved by the UI thread while recording.
levelreadonlyMotion<number>YesThe input level in dBFS, -160 (silence) to 0, when metering is on.
errorreadonlyReadonlySignal<string>Yes—
start() => Promise<void>YesStarts a new file, asking for the microphone first, or resumes a paused one.
pause() => Promise<void>Yes—
stop() => Promise<Recording>YesFinishes the file and resolves its file:// URI, in the cache directory.
start — method signatures

Signatures

ts
(): Promise<void>

Parameters

No parameters.

Returns

Promise<void>

pause — method signatures

Signatures

ts
(): Promise<void>

Parameters

No parameters.

Returns

Promise<void>

stop — method signatures

Signatures

ts
(): Promise<Recording>

Parameters

No parameters.

Returns

Promise<AudioRecording>

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