Skip to content

Commit

Permalink
Merge pull request #9 from Sanan4li/main
Browse files Browse the repository at this point in the history
added callbacks for recording functions
  • Loading branch information
sankaSanjeeva authored Aug 21, 2024
2 parents b563707 + 8f53236 commit a1153b0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ function App() {
disabled={
!(recordingStatus === "recording" || recordingStatus === "paused")
}
onClick={stopRecording}
onClick={() => {
stopRecording((blob) => {
console.log(blob);
});
}}
>
Stop
</button>
Expand Down
7 changes: 5 additions & 2 deletions src/hooks/audio-recorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ const useAudioRecorder = () => {
});
};

const stopRecording = () => {
recorderRef.current?.stopRecording(() => {
const stopRecording = (
callBack?: (blob?: Blob, blobURL?: string) => void
) => {
recorderRef.current?.stopRecording((blobURL: string) => {
recorderRef.current.microphone.stop();
setRecordingStatus("stopped");
setRecordingTime(0);
callBack?.(recorderRef.current?.getBlob(), blobURL);
});
};

Expand Down

0 comments on commit a1153b0

Please sign in to comment.