chrisguttandin/extendable-media-recorder

Pause and Resume

Closed this issue · 7 comments

Hi, Thanks for the effort, great job.

I am building a react audio recorder that pauses recording when there is no audio (volume is lower than a specific value), and I'm using your awesome package to get the audio file in .wav format.

When I tried to use the pause and resume methods it showed a pause is not a function error, also pause is undefined.

Screenshot from 2021-07-06 18-10-32

Is pause and resume not implemented ? If they are not, do you plan to ?

Hi @MartinEmilEshack, thanks for your nice words.

If I remember correctly the pause/resume mechanism was added to the API after I started with the project and I never got around adding it. However the implementation should be straightforward.

But I'm afraid it won't be very precise (like the start/stop methods). Would that work for your use case?

But I'm afraid it won't be very precise (like the start/stop methods).

Could you please elaborate, what do you mean it won't be precise ?

It will have the same precision as calling start() or stop(). It's sending a message to another thread which then starts or stops (or pauses or resumes) the recording. That most likely happens almost immediately but it does also sometimes take a little longer. There is no way to accurately predict how fast the other thread reacts.

Does that make sense?

I didn't know the package functioned like that.
It's ok with me, stop() and start() behave pretty fine, It's unnoticeable.

Just being curious, why did you take this approach?

It wasn't my decision. :-) It's defined like that in the MediaStream Recording spec. Here is for example the text which defines pause(): https://w3c.github.io/mediacapture-record/#dom-mediarecorder-pause

But since the goal of this package is to offer a drop-in replacement for the native MediaRecoder and the native MediaRecorder also gets used internally, I also copied this behavior for the browsers which need a polyfill.

Yeah It all makes sense now. Thanks for explaining all of this to me.
Let me know when you add the pause() and resume() functions if you're gonna, I will use them in my grad project.
Great Work. 👏 👏

Hi @MartinEmilEshack, v6.5.0 finally supports the pause() and resume() methods. Please let me know if you run into any issues using them.