Skip to content

Commit 3838188

Browse files
authored
Fix download issues (#59)
* Add ffmpeg to convert webm to mp3/wav * Add migration message * Linting
1 parent 5694c7b commit 3838188

File tree

7 files changed

+1400
-691
lines changed

7 files changed

+1400
-691
lines changed

.eslintrc.json

+7-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,13 @@
3535
}
3636
],
3737
"react-hooks/exhaustive-deps": "off",
38-
"@typescript-eslint/strict-boolean-expressions": "off"
39-
38+
"@typescript-eslint/strict-boolean-expressions": "off",
39+
"@typescript-eslint/no-floating-promises": [
40+
"error",
41+
{
42+
"ignoreVoid": true
43+
}
44+
]
4045
},
4146
"ignorePatterns": ["src/main.tsx", "src/vite-env.d.ts"]
4247
}

README.md

+13-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ An audio recording helper for React. Provides a component and a hook to help wit
77
npm install react-audio-voice-recorder
88
```
99

10+
```sh
11+
yarn add react-audio-voice-recorder
12+
```
13+
14+
## Migrating from v1 → v2
15+
### Breaking changes
16+
- In v2 the `AudioRecorder` prop `downloadFileExtension` no longer supports `mp3` and `wav` without the website using this package being [cross-origin isolated](https://web.dev/cross-origin-isolation-guide/). This change was made in order to fix [issue #54](https://github.com/samhirtarif/react-audio-recorder/issues/54) in v1.2.1
17+
1018
## Usage
1119

1220
### **AudioRecorder** Component ([Usage](https://stackblitz.com/edit/react-ts-cc5l47?file=App.tsx))
@@ -35,7 +43,7 @@ ReactDOM.createRoot(document.getElementById("root")).render(
3543
echoCancellation: true,
3644
}}
3745
downloadOnSavePress={true}
38-
downloadFileExtension="mp3"
46+
downloadFileExtension="webm"
3947
/>
4048
</React.StrictMode>
4149
);
@@ -47,9 +55,12 @@ ReactDOM.createRoot(document.getElementById("root")).render(
4755
| **`audioTrackConstraints`** | Takes a [subset](https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackSettings#instance_properties_of_audio_tracks) of `MediaTrackConstraints` that apply to the audio track | N/A | Yes
4856
| **`onNotAllowedOrFound`** | This gets called when the `getUserMedia` promise is rejected. It takes the resultant `DOMException` as its parameter | N/A | Yes
4957
| **`downloadOnSavePress`** | A `boolean` value that determines if the recording should be downloaded when "Save recording" option is pressed | `false` | Yes |
50-
| **`downloadFileExtension`** | The file extension to be used for the downloaded file. Allowed values are `mp3`, `wav` and `webm` | `mp3` | Yes |
58+
| **`downloadFileExtension`** | The file extension to be used for the downloaded file. Allowed values are `webm`, `mp3` and `wav`. In order to use `mp3` or `wav` please ensure that your website is [cross-origin isolated](https://web.dev/cross-origin-isolation-guide/). [Further reading](https://web.dev/coop-coep/) | `webm` | Yes |
5159
| **`showVisualizer`** | Displays a waveform visualization for the audio when set to `true` | `false` | Yes |
5260
| **`classes`** | This allows class names to be passed to modify the styles for the entire component or specific portions of it | N/A | Yes |
61+
62+
**NOTE: In order for `mp3` and `wav` downloading to work properly, your website needs to be [cross-origin isolated](https://web.dev/cross-origin-isolation-guide/). This is necessary because this package uses [FFmpeg](https://www.npmjs.com/package/@ffmpeg/ffmpeg) which internally uses `SharedArrayBuffer` that requires cross-origin isolation**
63+
5364
---
5465
### **useAudioRecorder** hook
5566

0 commit comments

Comments
 (0)