use-media-recorder icon indicating copy to clipboard operation
use-media-recorder copied to clipboard

Error when calling stopRecording() immediately after recording starts

Open willdspd opened this issue 2 years ago • 1 comments

If I call stopRecording() immediately after the recording starts (more specifically when status === "recording"), I get the following error: TypeError: undefined is not an object (evaluating 'sampleChunk.type')

If I wait maybe 1 or 2 seconds after the recording starts and call stopRecording(), everything works as intended. It seems like there should be another 'status' between 'ready' and 'recording' that could help us identify when it is safe to call stopRecording().

As a workaround, I've created my own isInitializing state which turns true when status === "ready", and then using a setTimeout, turns back to false 2000ms after status === "recording". Then I simply show a loading spinner instead of the stop button when isInitializing === true. I imagine you could just include a property like this (just not using setTimeout) into the actual status property itself.

I am using the 1.5.0-beta.0 version

willdspd avatar Apr 16 '22 20:04 willdspd

Hi @williamdespard Thanks for filing this Not sure I understood the issue correctly Having trouble re-creating it manually on Chrome Version 100.0.4896.88 (Official Build) (64-bit) - see samples below

A few questions if you don't mind

Are they happening in a different browser or the same one*(Chrome Version 100.0.4896.88)*? Would you mind sharing a sample sandbox or recording demonstrating the issue?

Apologies for the lack of proper documentation 😅 to assist with issue reporting and change logs. Will be sure to set those up soon

Version 1.5.0-beta.0 only changes the live stream from video only to video + audio (#19 )


Attempt recreation A (share -> record -> stop)

use-media-recorder-bug

Attempt recreation B (record[auto request share] -> stop)

use-media-recorder-bug-next

Sandbox

wmik avatar Apr 18 '22 06:04 wmik