audio.AudioRecorder
A native recorder the scope that made it owns (docs/audio.md).
Usage
Configure a component-owned voice recorder.
This type is used by audio.recorder
// 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
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
| Name | Type | Required | Description |
|---|---|---|---|
idreadonly | number | Yes | — |
recordingreadonly | ReadonlySignal<boolean> | Yes | — |
timereadonly | Motion<number> | Yes | Seconds recorded so far, moved by the UI thread while recording. |
levelreadonly | Motion<number> | Yes | The input level in dBFS, -160 (silence) to 0, when metering is on. |
errorreadonly | ReadonlySignal<string> | Yes | — |
start | () => Promise<void> | Yes | Starts a new file, asking for the microphone first, or resumes a paused one. |
pause | () => Promise<void> | Yes | — |
stop | () => Promise<Recording> | Yes | Finishes the file and resolves its file:// URI, in the cache directory. |
start — method signatures
Signatures
(): Promise<void>Parameters
No parameters.
Returns
Promise<void>
pause — method signatures
Signatures
(): Promise<void>Parameters
No parameters.
Returns
Promise<void>
stop — method signatures
Signatures
(): 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.