Closed SupertigerDev closed 3 months ago
I'm using it in a react + vite application and I managed to use it like this:
import OpusMediaRecorder from 'opus-media-recorder';
import OggOpusWasm from 'opus-media-recorder/OggOpusEncoder.wasm?url';
import WebMOpusWasm from 'opus-media-recorder/WebMOpusEncoder.wasm?url';
import umd from 'opus-media-recorder/encoderWorker.umd.js?url';
export const AudioRecorder = (props) => {
...
mediaRecorder.current = new OpusMediaRecorder(
currentStream,
{ mimeType: 'audio/ogg' },
{
encoderWorkerFactory: (_: any) => new Worker(umd),
OggOpusEncoderWasmPath: OggOpusWasm,
WebMOpusEncoderWasmPath: WebMOpusWasm
}
);
...
}
Thanks! I figured it out, just forgot to close this issue. I also made an easy to use library for solidjs
I'm using it in a react + vite application and I managed to use it like this:
import OpusMediaRecorder from 'opus-media-recorder'; import OggOpusWasm from 'opus-media-recorder/OggOpusEncoder.wasm?url'; import WebMOpusWasm from 'opus-media-recorder/WebMOpusEncoder.wasm?url'; import umd from 'opus-media-recorder/encoderWorker.umd.js?url'; export const AudioRecorder = (props) => { ... mediaRecorder.current = new OpusMediaRecorder( currentStream, { mimeType: 'audio/ogg' }, { encoderWorkerFactory: (_: any) => new Worker(umd), OggOpusEncoderWasmPath: OggOpusWasm, WebMOpusEncoderWasmPath: WebMOpusWasm } ); ... }
Hi. Trying to use this package also in a React + Vite app. Followed your implementation but when the recording starts, I'm getting this error:
TypeError: AudioContext is not a constructor
Here's my vite.config
export default defineConfig({
plugins: [react()],
test: {
globals: true,
environment: "jsdom",
include: ["**/?(*.)test.ts?(x)"],
setupFiles: ["./setupTests.ts"],
},
define: {
global: {}, // fix Uncaught ReferenceError: global is not defined in opus-media-recorder
},
});
Any help would be appreciated. Thx.
Does anyone know how I could use this with Vite?