Verwendung

Configure a component-owned voice recorder.

Dieser Typ wird verwendet von 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().

Typdeklaration

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

Mitglieder 8

NameTypErforderlichBeschreibung
idschreibgeschütztnumberJa—
recordingschreibgeschütztReadonlySignal<boolean>Ja—
timeschreibgeschütztMotion<number>JaSeconds recorded so far, moved by the UI thread while recording.
levelschreibgeschütztMotion<number>JaThe input level in dBFS, -160 (silence) to 0, when metering is on.
errorschreibgeschütztReadonlySignal<string>Ja—
start() => Promise<void>JaStarts a new file, asking for the microphone first, or resumes a paused one.
pause() => Promise<void>Ja—
stop() => Promise<Recording>JaFinishes the file and resolves its file:// URI, in the cache directory.
start — Methodensignaturen

Signaturen

ts
(): Promise<void>

Parameter

Keine Parameter.

Rückgabe

Promise<void>

pause — Methodensignaturen

Signaturen

ts
(): Promise<void>

Parameter

Keine Parameter.

Rückgabe

Promise<void>

stop — Methodensignaturen

Signaturen

ts
(): Promise<Recording>

Parameter

Keine Parameter.

Rückgabe

Promise<AudioRecording>

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