# audio-recorder-polyfill
**Repository Path**: mirrors_ai/audio-recorder-polyfill
## Basic Information
- **Project Name**: audio-recorder-polyfill
- **Description**: MediaRecorder polyfill to record audio in Edge and Safari
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2021-01-26
- **Last Updated**: 2026-05-17
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# Audio Recorder Polyfill
> [!WARNING]
> **Deprecated: You do not need this polyfill for modern browsers**
[MediaRecorder] polyfill to record audio in Edge and Safari.
Try it in **[online demo]** and see **[API]**.
* **Spec compatible.** In the future when all browsers will support
MediaRecorder, you will remove polyfill.
* **Small.** 1.11 KB (minified and gzipped). No dependencies.
It uses [Size Limit] to control size.
* **One file.** In contrast to other recorders, this polyfill uses
“inline worker” and don’t need a separated file for Web Worker.
* **MP3** and **WAV** encoder support.
```js
navigator.mediaDevices.getUserMedia({ audio: true }).then(stream => {
recorder = new MediaRecorder(stream)
recorder.addEventListener('dataavailable', e => {
audio.src = URL.createObjectURL(e.data)
})
recorder.start()
})
```
[MediaRecorder]: https://developers.google.com/web/updates/2016/01/mediarecorder
[online demo]: https://ai.github.io/audio-recorder-polyfill/
[Size Limit]: https://github.com/ai/size-limit
[API]: https://ai.github.io/audio-recorder-polyfill/api/
## Install
Install package:
```sh
npm install --save audio-recorder-polyfill
```
We recommend creating separated webpack/Parcel bundle with polyfill.
In this case, polyfill will be downloaded only by Edge and Safari.
Good browsers will download less.
Files recorded without the polyfill will not be playable on Safari,
it is highly recommended to convert it to MP3 on the back-end
of your application. If that’s not an option you can use the polyfill
in all browsers to force the audio to be converted to the right format
with the price of client’s performance.
```diff
entry: {
app: './src/app.js',
+ polyfill: './src/polyfill.js'
}
```
Install polyfill as MediaRecorder in this new bundle `src/polyfill.js`:
```js
import AudioRecorder from 'audio-recorder-polyfill'
window.MediaRecorder = AudioRecorder
```
Add this code to your HTML to load this new bundle only for browsers
without MediaRecorder support:
```diff
+
```
## ES Modules
Polyfill supports ES modules. You do not need to do anything for bundlers.
For quick hacks you can load polyfill from CDN. Do not use it in production
because of low performance.
```js
import AudioRecorder from 'https://cdn.jsdelivr.net/npm/audio-recorder-polyfill/index.js'
window.MediaRecorder = AudioRecorder
```
## Usage
In the beginning, we need to show a warning in browsers without Web Audio API:
```js
if (MediaRecorder.notSupported) {
noSupport.style.display = 'block'
dictaphone.style.display = 'none'
}
```
Then you can use standard MediaRecorder [API]:
```js
let recorder
recordButton.addEventListener('click', () => {
// Request permissions to record audio
navigator.mediaDevices.getUserMedia({ audio: true }).then(stream => {
recorder = new MediaRecorder(stream)
// Set record to