Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,19 @@ This is for scenarios where you would wish to control the `AudioRecorder` compon
import { AudioRecorder, useAudioRecorder } from 'react-audio-voice-recorder';

const ExampleComponent = () => {
const [audioElement, setAudioElement] =
useState<
ReactElement<
{ src: string; controls: boolean },
string | JSXElementConstructor<any>
>
>();

const recorderControls = useAudioRecorder()
const addAudioElement = (blob) => {
const url = URL.createObjectURL(blob);
const audio = document.createElement("audio");
audio.src = url;
audio.controls = true;
document.body.appendChild(audio);
const Audio = React.createElement("audio", { src: url, controls: true });
setAudioElement(Audio);
};

return (
Expand All @@ -145,6 +151,7 @@ const ExampleComponent = () => {
/>
<button onClick={recorderControls.stopRecording}>Stop recording</button>
</div>
{audioElement}
)
}
```
Expand Down