From 360f41a0d5f35da890f1e0ffec2521cdaa72b764 Mon Sep 17 00:00:00 2001 From: Nico Moschopoulos Date: Sun, 6 Oct 2024 22:07:48 -0400 Subject: [PATCH] Adds a start param --- src/hooks/useAudioRecorder.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/hooks/useAudioRecorder.ts b/src/hooks/useAudioRecorder.ts index 18db0eab..996e6ffc 100644 --- a/src/hooks/useAudioRecorder.ts +++ b/src/hooks/useAudioRecorder.ts @@ -37,15 +37,19 @@ export type MediaAudioTrackConstraints = Pick< * @details `isPaused`: A boolean value that represents whether a recording in progress is paused * @details `recordingTime`: Number of seconds that the recording has gone on. This is updated every second * @details `mediaRecorder`: The current mediaRecorder in use + * + * @details `start`: The timeslice in seconds to record into each blob {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder/start#timeslice} */ const useAudioRecorder: ( audioTrackConstraints?: MediaAudioTrackConstraints, onNotAllowedOrFound?: (exception: DOMException) => any, - mediaRecorderOptions?: MediaRecorderOptions + mediaRecorderOptions?: MediaRecorderOptions, + start?: number ) => recorderControls = ( audioTrackConstraints, onNotAllowedOrFound, - mediaRecorderOptions + mediaRecorderOptions, + start ) => { const [isRecording, setIsRecording] = useState(false); const [isPaused, setIsPaused] = useState(false); @@ -81,7 +85,7 @@ const useAudioRecorder: ( mediaRecorderOptions ); setMediaRecorder(recorder); - recorder.start(); + recorder.start(start); _startTimer(); recorder.addEventListener("dataavailable", (event) => {