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.52k stars 1.75k forks source link

Uncaught TypeError: Cannot read property 'toString' of undefined at MediaRecorder.mediaRecorder.onerror (RecordRTC.js:1990) #426

Open realtek8723 opened 6 years ago

realtek8723 commented 6 years ago

Hi, Muaz Khan

I have an issue in chrome. Uncaught TypeError: Cannot read property 'toString' of undefined at MediaRecorder.mediaRecorder.onerror (RecordRTC.js:1990) .

previously it worked fine. Can you help me solving this issue. This is the code where i'm getting the error. The mediaStream is stopped recording.

    mediaRecorder.onerror = function(error) {
        if (!config.disableLogs) {
            // via: https://w3c.github.io/mediacapture-record/MediaRecorder.html#exception-summary
            if (error.name.toString().toLowerCase().indexOf('invalidstate') !== -1) {
                console.error('The MediaRecorder is not in a state in which the proposed operation is allowed to be executed.', error);
            } else if (error.name.toString().toLowerCase().indexOf('notsupported') !== -1) {
                console.error('MIME type (', config.mimeType, ') is not supported.', error);
            } else if (error.name.toString().toLowerCase().indexOf('security') !== -1) {
                console.error('MediaRecorder security error', error);
            }

            // older code below
            else if (error.name === 'OutOfMemory') {
                console.error('The UA has exhaused the available memory. User agents SHOULD provide as much additional information as possible in the message attribute.', error);
            } else if (error.name === 'IllegalStreamModification') {
                console.error('A modification to the stream has occurred that makes it impossible to continue recording. An example would be the addition of a Track while recording is occurring. User agents SHOULD provide as much additional information as possible in the message attribute.', error);
            } else if (error.name === 'OtherRecordingError') {
                console.error('Used for an fatal error other than those listed above. User agents SHOULD provide as much additional information as possible in the message attribute.', error);
            } else if (error.name === 'GenericError') {
                console.error('The UA cannot provide the codec or recording option that has been requested.', error);
            } else {
                console.error('MediaRecorder Error', error);
            }
        }           
        (function(looper) {
            if (!self.manuallyStopped && mediaRecorder && mediaRecorder.state === 'inactive') {
                delete config.timeslice;

                // 10 minutes, enough?
                mediaRecorder.start(10 * 60 * 1000);
                return;
            }

            setTimeout(looper, 1000);
        })();

        if (mediaRecorder.state !== 'inactive' && mediaRecorder.state !== 'stopped') {
            mediaRecorder.stop();
        }
    }; 
muaz-khan commented 6 years ago
mediaRecorder.onerror = function(error) {
    if (!error) {
        return;
    }

    if (!error.name) {
        error.name = 'UnknownError';
    }

    // rest of the code goes here
};
realtek8723 commented 6 years ago

Hi, I appreciate your quick response,Thanks!! Yes, I tried the above code snippet but the recording is stopped anyway. I will share the screenshot of console. please take a look into it. Thank you in Advance.

errorrecordrtc

muaz-khan commented 6 years ago

Please share complete demo. I want to check if MediaStream is still active, including all its tracks.