Skip to content

Commit

Permalink
#47 - using lowest interval i.e. 1-milisecond
Browse files Browse the repository at this point in the history
Chrome accepts “0” but Firefox assumes that “0” means
no-ondataavailable until “stop” or “requestData” is invoked.
  • Loading branch information
muaz-khan committed Oct 8, 2015
1 parent a96250b commit 2446780
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 40 deletions.
41 changes: 22 additions & 19 deletions RecordRTC.js
@@ -1,4 +1,4 @@
// Last time updated at Thursday, October 8th, 2015, 4:58:38 PM
// Last time updated at Thursday, October 8th, 2015, 11:21:03 PM

// links:
// Open-Sourced: https://github.com/muaz-khan/RecordRTC
Expand Down Expand Up @@ -1456,7 +1456,6 @@ function MediaStreamRecorder(mediaStream, config) {

if (e.data && e.data.size) {
recordedBuffers.push(e.data);
return;
}
};

Expand Down Expand Up @@ -1494,7 +1493,7 @@ function MediaStreamRecorder(mediaStream, config) {
// handler. "mTimeSlice < 0" means Session object does not push encoded data to
// onDataAvailable, instead, it passive wait the client side pull encoded data
// by calling requestData API.
mediaRecorder.start(3 * 1000);
mediaRecorder.start(1);

// Start recording. If timeSlice has been provided, mediaRecorder will
// raise a dataavailable event containing the Blob of collected data on every timeSlice milliseconds.
Expand Down Expand Up @@ -1524,6 +1523,8 @@ function MediaStreamRecorder(mediaStream, config) {
return;
}

this.recordingCallback = callback || function() {};

// mediaRecorder.state === 'recording' means that media recorder is associated with "session"
// mediaRecorder.state === 'stopped' means that media recorder is detached from the "session" ... in this case; "session" will also be deleted.

Expand All @@ -1534,24 +1535,26 @@ function MediaStreamRecorder(mediaStream, config) {
}

if (recordedBuffers.length) {
/**
* @property {Blob} blob - Recorded frames in video/webm blob.
* @memberof MediaStreamRecorder
* @example
* recorder.stop(function() {
* var blob = recorder.blob;
* });
*/
this.blob = new Blob(recordedBuffers, {
type: config.mimeType || 'video/webm'
});
this.onRecordingFinished();
}
};

if (callback) {
callback();
}
this.onRecordingFinished = function() {
/**
* @property {Blob} blob - Recorded frames in video/webm blob.
* @memberof MediaStreamRecorder
* @example
* recorder.stop(function() {
* var blob = recorder.blob;
* });
*/
this.blob = new Blob(recordedBuffers, {
type: config.mimeType || 'video/webm'
});

recordedBuffers = [];
}
this.recordingCallback();

recordedBuffers = [];
};

/**
Expand Down

2 comments on commit 2446780

@kevin-frugier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@muaz-khan : are you not concerned about your choice of 1ms interval ? Concatenating 1ms chunks in JS sounds like a bad idea to me. Why not simply get the data given by the browser when stop is called ?

2446780#diff-9e4d7457e8b7dfa0c9da529d9083fdd3R1496

@muaz-khan
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: b1e63b0

Please sign in to comment.