new MediaStreamRecorder(mediaStream, config)
Runs top over MediaRecorder API.
MediaStreamRecorder is an abstraction layer for MediaRecorder API. It is used by RecordRTC to record MediaStream(s) in both Chrome and Firefox.
Parameters:
Name | Type | Description |
---|---|---|
mediaStream |
MediaStream | MediaStream object fetched using getUserMedia API or generated using captureStreamUntilEnded or WebAudio API. |
config |
object | {disableLogs:true, initCallback: function, mimeType: "video/webm", timeSlice: 1000} |
- License:
- Source:
- See:
Throws:
Will throw an error if first argument "MediaStream" is missing. Also throws error if "MediaRecorder API" are not supported by the browser.
Example
var config = {
mimeType: 'video/webm', // vp8, vp9, h264, mkv, opus/vorbis
audioBitsPerSecond : 256 * 8 * 1024,
videoBitsPerSecond : 256 * 8 * 1024,
bitsPerSecond: 256 * 8 * 1024, // if this is provided, skip above two
checkForInactiveTracks: true,
timeSlice: 1000, // concatenate intervals based blobs
ondataavailable: function() {} // get intervals based blobs
}
var recorder = new MediaStreamRecorder(mediaStream, config);
recorder.record();
recorder.stop(function(blob) {
video.src = URL.createObjectURL(blob);
// or
var blob = recorder.blob;
});
Members
(static) this.blob
Properties:
Name | Type | Description |
---|---|---|
blob |
Blob | Recorded data as "Blob" object. |
- Source:
Example
recorder.stop(function() {
var blob = recorder.blob;
});
(static) this.blob
Properties:
Name | Type | Description |
---|---|---|
blob |
Blob | Recorded data as "Blob" object. |
- Source:
Example
recorder.stop(function() {
var blob = recorder.blob;
});
(static) this.timestamps
Properties:
Name | Type | Description |
---|---|---|
timestamps |
Array | Array of time stamps |
- Source:
Example
console.log(recorder.timestamps);
(static) this.timestamps
Properties:
Name | Type | Description |
---|---|---|
timestamps |
Array | Array of time stamps |
- Source:
Example
console.log(recorder.timestamps);
Methods
(static) this.clearRecordedData()
This method resets currently recorded data.
- Source:
Example
recorder.clearRecordedData();
(static) this.clearRecordedData()
This method resets currently recorded data.
- Source:
Example
recorder.clearRecordedData();
(static) this.getAllStates() → {Array}
Get MediaRecorder all recording states.
- Source:
Returns:
Returns all recording states
- Type
- Array
Example
var state = recorder.getAllStates();
(static) this.getAllStates() → {Array}
Get MediaRecorder all recording states.
- Source:
Returns:
Returns all recording states
- Type
- Array
Example
var state = recorder.getAllStates();
(static) this.getArrayOfBlobs() → {Array}
This method returns array of blobs. Use only with "timeSlice". Its useful to preview recording anytime, without using the "stop" method.
- Source:
Returns:
Returns array of recorded blobs.
- Type
- Array
Example
var arrayOfBlobs = recorder.getArrayOfBlobs();
(static) this.getArrayOfBlobs() → {Array}
This method returns array of blobs. Use only with "timeSlice". Its useful to preview recording anytime, without using the "stop" method.
- Source:
Returns:
Returns array of recorded blobs.
- Type
- Array
Example
var arrayOfBlobs = recorder.getArrayOfBlobs();
(static) this.getState() → {String}
Get MediaRecorder readonly state.
- Source:
Returns:
Returns recording state.
- Type
- String
Example
var state = recorder.getState();
(static) this.getState() → {String}
Get MediaRecorder readonly state.
- Source:
Returns:
Returns recording state.
- Type
- String
Example
var state = recorder.getState();
(static) this.pause()
This method pauses the recording process.
- Source:
Example
recorder.pause();
(static) this.pause()
This method pauses the recording process.
- Source:
Example
recorder.pause();
(static) this.record()
This method records MediaStream.
- Source:
Example
recorder.record();
(static) this.record()
This method records MediaStream.
- Source:
Example
recorder.record();
(static) this.resume()
This method resumes the recording process.
- Source:
Example
recorder.resume();
(static) this.resume()
This method resumes the recording process.
- Source:
Example
recorder.resume();
(static) this.stop(callback)
This method stops recording MediaStream.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function | Callback function, that is used to pass recorded blob back to the callee. |
- Source:
Example
recorder.stop(function(blob) {
video.src = URL.createObjectURL(blob);
});
(static) this.stop(callback)
This method stops recording MediaStream.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function | Callback function, that is used to pass recorded blob back to the callee. |
- Source:
Example
recorder.stop(function(blob) {
video.src = URL.createObjectURL(blob);
});