chrisguttandin / extendable-media-recorder

An extendable drop-in replacement for the native MediaRecorder.
MIT License
258 stars 13 forks source link

Uncaught (in promise) Error: There was no instance of an encoder stored with the given id. #640

Closed FrenchMajesty closed 3 years ago

FrenchMajesty commented 3 years ago

Hello,

I get this error whenever I attempt to start a recording for the 2nd time.

module.ts:49 Uncaught (in promise) Error: There was no instance of an encoder stored with the given id.
    at Worker.<anonymous> (module.ts:49)

On first run it goes all as expected and works well. However, when I try to start a 2nd recording it fails.

Here is my AudioRecorder class which is what I use to capture audio:

image

Here is the logic from the React component:

image

chrisguttandin commented 3 years ago

Hi @FrenchMajesty, thanks for making me aware of this. I think this is just an oversight on my end. The MediaRecorder is currently implemented in a way which only allows it to be used once. As a quick fix you could recreate a new MediaRecorder whenever start() is called.

FrenchMajesty commented 3 years ago

@chrisguttandin I attempted to use your quick fix of just re-creating a new MediaRecorder every time i need to record, however my app still crashes with the following error:

Unhandled Rejection (Error): Another request was made to initiate an encoding. Worker. src/module.ts:49

Screen Shot 2021-04-02 at 9 55 18 AM
chrisguttandin commented 3 years ago

I believe the issue is fixed now. I added some tests which check that a MediaRecorder can be used twice and fixed the errors that caused those tests to fail. The update is up on npm as v6.1.54.

Please let me know if you still experience any issues.