Utilisation

Configure a component-owned voice recorder.

Ce type est utilisé par 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().

Déclaration du type

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

Membres 8

NomTypeRequisDescription
idlecture seulenumberOui—
recordinglecture seuleReadonlySignal<boolean>Oui—
timelecture seuleMotion<number>OuiSeconds recorded so far, moved by the UI thread while recording.
levellecture seuleMotion<number>OuiThe input level in dBFS, -160 (silence) to 0, when metering is on.
errorlecture seuleReadonlySignal<string>Oui—
start() => Promise<void>OuiStarts a new file, asking for the microphone first, or resumes a paused one.
pause() => Promise<void>Oui—
stop() => Promise<Recording>OuiFinishes the file and resolves its file:// URI, in the cache directory.
start — signatures de méthode

Signatures

ts
(): Promise<void>

Paramètres

Aucun paramètre.

Retourne

Promise<void>

pause — signatures de méthode

Signatures

ts
(): Promise<void>

Paramètres

Aucun paramètre.

Retourne

Promise<void>

stop — signatures de méthode

Signatures

ts
(): Promise<Recording>

Paramètres

Aucun paramètre.

Retourne

Promise<AudioRecording>

Généré depuis les déclarations TypeScript publiques : signatures, props et valeurs par défaut viennent de la source vérifiée, les descriptions de sa JSDoc. Aucune valeur par défaut n'est inventée.