Calm motion: animations on this site only fade, with no movement
AudioRecorder
Record from the microphone, with a preview
Records a voice note, a comment, or an answer, in the browser, with the native MediaRecorder. People hear the recording before your app uploads it. To play a file, use the audio player. To show the shape of a sound, use the waveform.
Basic
- Record asks for the microphone. The browser asks for permission only then, not when the page opens.
- While it records, bars show the loudness, and the clock counts. Pause stops the clock and the recording, and Resume continues the same recording.
- Stop releases the microphone, sends the recording as a
Blobwithrecord, and shows a player for it. Record again starts a new one. maxDurationstops the recording after that many seconds.mimeTypeasks for a type, for exampleaudio/webmoraudio/mp4, if the browser supports it. Otherwise the browser chooses.- When there is no microphone or no permission, a line says so, and
errorsends the reason. Record stays, so people can try again after they allow it. - A status line says "Recording", "Paused", and the length when it stops, so a screen reader follows the state. The bars are hidden from screen readers.
- The microphone needs a secure page (HTTPS or
localhost). - Change the words with
labelsor a label pack: the buttons and the status words.
Usage
ts
import { BlessAudioRecorder } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
maxDuration | number | — | stop by itself after this many seconds |
mimeType | string | — | a type for MediaRecorder, for example `audio/webm`; used when the browser supports it |
bars | number | 40 | level bars drawn while recording |
labels | Partial<{ record: string; pause: string; resume: string; stop: string; again: string; recording: string; paused: string; done: string; unavailable: string; }> | — |
Events
| Name | Payload | Description |
|---|---|---|
error | [error: unknown] | |
record | [audio: Blob] |