Closed peracc closed 5 years ago
Hi, I have a few questions for you to get a better answer:
navigator.mediaDevices.getUserMedia({ audio: true }).then()
is called? How do you call startRecording
? in some browsers you must call getUserMedia()
in user-initiated callback, such as button click.@kbumsik I updated the code above to fit more my use-case.
1) Yes, I debugged it to be sure then
is being called. startRecording
is called from button onClick
event, but the getUserMedia
is called from React lifecycle function componentDidMount
. I didn't have any problems with native MediaRecorder in both Firefox and Chrome.
2) Currently I'm testing it in last releases of Chrome and Firefox, but my main goal is to make it possible to record ogg-opus in Safari 12.
A little update on errors. Just found out an error in Firefox (chrome console doesn't log this) console output after recording started:
ReferenceError: require is not defined encoderWorker.js:2:23
My guess is I can't just refer to encoderWorker.js
in my PUBLIC
f older and I HAVE to use a webpack.config.js
instead.
@peracc No you can't. You have to have actual files in PUBLIC/opus-media-recorder
. You should either manually copy the files (encoderWorker.js
, OggOpusEncoder.wasm
, WebMOpusEncoder.wasm
all of them. Usually located node_modules/opus-media-recorder
) to PUBLIC/opus-media-recorder
or use a bundler like Webpack.
Well it is actually what I did: copied all files to the PUBLIC/opus-media-recorder
. But as I mentioned above it doesn't work for me.
same issue here, cannot work with create-react-app, for the same error message
@peracc @Felix-Indoing Sorry about that. If you use it without bundler then I think you will need to use encoderWorker.umd.js
, not encoderWorker.js
. I should've document it.
Also could you provide a full source code of your work? So that I could include create-react-app integration example in the documentation as well.
@kbumsik This fixed the
ReferenceError: require is not defined encoderWorker.js:2:23
error in the Firefox, but the 'dataavailable' event is still not being called :/
Hi, I made a create-react-app example in create-react-app
branch. I can reproduce the problem you stated, and this unexpected behavior. I'm currently figuring out a fix...
@peracc @Felix-Indoing Fixed in d7e4a12. The fix is included in the new version 0.7.19
. Please check it out and tell me if it works, if you have time :)
Thank you very much for reporting!
I had a similar problem and for CRA it's much more simpler to go with the cdn approach
I'm trying to use the opus recorder with React's 'create-react-app'. I use the code from the docs:
All the needed files I put into my
PUBLIC
folder which is referenced byprocess.env.PUBLIC_URL
. However, thedataavailable
event is never fired and so there is no any console output.