Search code examples
javascriptblobwebrtcjsfiddle

blob not storing any value for any reason


Recording a video with webRTC I have no data, and after debugging I just realized that there's no content in the Blob variable (that must store the video).

According to the code I pasted on my jsfiddle, line 136 should contain something like:

Blob {type: "audio/wav", size: 360492, slice: function}size: 360492type: "audio/wav"

But its value is undefined.

Could anybody tell me what am I doing wrongly?


Solution

  • You have to call stopRecording and get the blob within the callback. The callback will also be passed a data URL.

    if (!isFirefox) {
        recordAudio.stopRecording(function(dataURL){
            var bloba = recordAudio.getBlob();
            console.log("Audio Blob",bloba);
        });
        fileType = 'audio';
        fileName = 'test.wav';
    } else {
        recordAudio.stopRecording(function(dataURL){
            var bloba = recordAudio.getBlob();
            console.log("Audio Blob",bloba);
        });
        fileType = 'video';
        fileName = 'test.webm';
    }
    if (!isFirefox) {
        recordVideo.stopRecording(function(dataURL){
            var blobv = recordVideo.getBlob();
            console.log("Video Blob",blobv);
        });
        fileType = 'video';
        fileName = 'test.webm';
    }
    

    Updated Fiddle