Skip to content

Commit

Permalink
tiny updates in the dev/RecordRTC.promises.js
Browse files Browse the repository at this point in the history
  • Loading branch information
muaz-khan committed Jan 13, 2019
1 parent e5147b7 commit 5dd23a8
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 17 deletions.
24 changes: 18 additions & 6 deletions RecordRTC.js
@@ -1,9 +1,9 @@
'use strict';

// Last time updated: 2019-01-11 12:28:08 PM UTC
// Last time updated: 2019-01-13 11:46:56 AM UTC

// ________________
// RecordRTC v5.5.1
// RecordRTC v5.5.2

// Open-Sourced: https://github.com/muaz-khan/RecordRTC

Expand Down Expand Up @@ -773,7 +773,7 @@ function RecordRTC(mediaStream, config) {
* @example
* alert(recorder.version);
*/
version: '5.5.1'
version: '5.5.2'
};

if (!this) {
Expand All @@ -791,7 +791,7 @@ function RecordRTC(mediaStream, config) {
return returnObject;
}

RecordRTC.version = '5.5.1';
RecordRTC.version = '5.5.2';

if (typeof module !== 'undefined' /* && !!module.exports*/ ) {
module.exports = RecordRTC;
Expand Down Expand Up @@ -5541,6 +5541,12 @@ function RecordRTCPromisesHandler(mediaStream, options) {
try {
self.recordRTC.stopRecording(function(url) {
self.blob = self.recordRTC.getBlob();

if (!self.blob || !self.blob.size) {
reject('Empty blob.', self.blob);
return;
}

resolve(url);
});
} catch (e) {
Expand Down Expand Up @@ -5578,11 +5584,17 @@ function RecordRTCPromisesHandler(mediaStream, options) {
* @memberof RecordRTCPromisesHandler
* @example
* recorder.stopRecording().then(function() {
* var blob = recorder.getBlob();
* recorder.getBlob().then(function(blob) {})
* }).catch(errorCB);
*/
this.getBlob = function() {
return self.recordRTC.getBlob();
return new Promise(function(resolve, reject) {
try {
resolve(self.recordRTC.getBlob());
} catch (e) {
reject(e);
}
});
};

/**
Expand Down
6 changes: 3 additions & 3 deletions RecordRTC.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bower.json
@@ -1,6 +1,6 @@
{
"name": "recordrtc",
"version": "5.5.1",
"version": "5.5.2",
"authors": [
{
"name": "Muaz Khan",
Expand Down
16 changes: 14 additions & 2 deletions dev/RecordRTC.promises.js
Expand Up @@ -74,6 +74,12 @@ function RecordRTCPromisesHandler(mediaStream, options) {
try {
self.recordRTC.stopRecording(function(url) {
self.blob = self.recordRTC.getBlob();

if (!self.blob || !self.blob.size) {
reject('Empty blob.', self.blob);
return;
}

resolve(url);
});
} catch (e) {
Expand Down Expand Up @@ -111,11 +117,17 @@ function RecordRTCPromisesHandler(mediaStream, options) {
* @memberof RecordRTCPromisesHandler
* @example
* recorder.stopRecording().then(function() {
* var blob = recorder.getBlob();
* recorder.getBlob().then(function(blob) {})
* }).catch(errorCB);
*/
this.getBlob = function() {
return self.recordRTC.getBlob();
return new Promise(function(resolve, reject) {
try {
resolve(self.recordRTC.getBlob());
} catch (e) {
reject(e);
}
});
};

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "recordrtc",
"preferGlobal": false,
"version": "5.5.1",
"version": "5.5.2",
"author": {
"name": "Muaz Khan",
"email": "muazkh@gmail.com",
Expand Down
9 changes: 5 additions & 4 deletions simple-demos/RecordRTCPromisesHandler.html
Expand Up @@ -30,10 +30,11 @@ <h1>Promises and RecordRTC</h1>

function stopRecordingCallback() {
video.srcObject = null;
var blob = recorder.getBlob();
video.src = URL.createObjectURL(blob);

recorder.camera.stop();

recorder.getBlob().then(function(blob) {
video.src = URL.createObjectURL(blob);
recorder.camera.stop();
});
}

var recorder; // globally accessible
Expand Down

0 comments on commit 5dd23a8

Please sign in to comment.