muaz-khan / RecordRTC

RecordRTC is WebRTC JavaScript library for audio/video as well as screen activity recording. It supports Chrome, Firefox, Opera, Android, and Microsoft Edge. Platforms: Linux, Mac and Windows.
https://www.webrtc-experiment.com/RecordRTC/
MIT License
6.46k stars 1.75k forks source link

Getting an error with StereoAudioRecorder URL.createObjectURL is not a function #808

Open devSarry opened 2 years ago

devSarry commented 2 years ago

Hello,

Amazing library. I'm trying to stream wav audio to my server and following the examples and reading some of the issues here I've set up the MediaStream and RecorderRTC as follows.

    const handleRecording = async () => {
        const mediaStream = await navigator.mediaDevices.getUserMedia({
            video: false,
            audio: true,
        });

        setStream(mediaStream);
        recorderRef.current = new RecordRTC(mediaStream, { type: 'audio',
            mimeType: 'audio/wav',
            recorderType: StereoAudioRecorder,
            numberOfAudioChannels: 1,
            desiredSampRate: 16000,
            timeSlice: 1000,
            ondataavailable: function(blob) {

                console.log('data to send')

            }
        });
        recorderRef.current.startRecording();
    };

    const handleStop = () => {
        recorderRef.current?.stopRecording(() => {

        })
    };

But its throwing an error as soon as the ondataavailable callback is called or I call stopRecording

image

devSarry commented 2 years ago

Playing around with this it has something to do with how imports are handled. To add a bit of context I'm trying to use this in a react typescript project. I npm installed the library via npm i @mrmaruf/recordrtc.

What I tested was loading the library via CDN in a script tag and not using the module imports and it worked fine. Do I need to setup some webworker outside new RecordRTC?

rbrazil commented 1 year ago

UNetbootin, which is both free and open source, is the best alternative. BalenaEtcher, YUMI, Ventoy, and dd are some other great apps like Rufus. Rufus alternatives primarily include Bootable USB Creators, but they may also include Disc Burners or CD Burners. Get more information rufus emmanuel lundberg.

mysteriousHerb commented 1 year ago

Playing around with this it has something to do with how imports are handled. To add a bit of context I'm trying to use this in a react typescript project. I npm installed the library via npm i @mrmaruf/recordrtc.

What I tested was loading the library via CDN in a script tag and not using the module imports and it worked fine. Do I need to setup some webworker outside new RecordRTC?

I also experience this problem with vue. Install via npm install recordrtc and import via import * as RecordRTC from 'recordrtc'; It will throw errors for MediaStreamRecorder not defined. but if using cdn in html script it just works..