Skip to content

Commit beddb4d

Browse files
committed
Added [email protected] Added "RecordRTCPromisesHandler"
1 parent 0ecec90 commit beddb4d

File tree

7 files changed

+100
-22
lines changed

7 files changed

+100
-22
lines changed

README.md

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ bower install recordrtc
136136
You can even link specific [releases](https://github.com/muaz-khan/RecordRTC/releases):
137137

138138
```html
139-
<!-- use 5.3.5 or any other version -->
140-
<script src="https://github.com/muaz-khan/RecordRTC/releases/download/5.3.5/RecordRTC.js"></script>
139+
<!-- use 5.3.6 or any other version -->
140+
<script src="https://github.com/muaz-khan/RecordRTC/releases/download/5.3.6/RecordRTC.js"></script>
141141
```
142142

143143
## How to capture stream?
@@ -756,6 +756,35 @@ recordRTC.getFromDisk(function(dataURL) {
756756

757757
In the above example; you can see that `recordRTC` instance object is used instead of global `RecordRTC` object.
758758

759+
## Promises
760+
761+
```html
762+
<script src="https://cdn.WebRTC-Experiment.com/RecordRTC.js"></script>
763+
764+
<!-- link this file as well -->
765+
<script src="/dev/RecordRTC.promises.js"></script>
766+
767+
<script>
768+
// use "RecordRTCPromisesHandler" instead of "RecordRTC"
769+
var recorder = new RecordRTCPromisesHandler(mediaStream, options);
770+
recorder.startRecording().then(function() {
771+
772+
}).catch(function(error) {
773+
//
774+
});
775+
776+
recorder.stopRecording().then(function(url) {
777+
var blob = recorder.blob;
778+
779+
recorder.getDataURL().then(function(dataURL) {
780+
//
781+
}).catch(function(error) {})
782+
}).catch(function(error) {
783+
//
784+
});
785+
</script>
786+
```
787+
759788
## Credits
760789

761790
1. [Recorderjs](https://github.com/mattdiamond/Recorderjs) for audio recording
@@ -783,16 +812,6 @@ The domain www.RecordRTC.org is open-sourced here:
783812
* Disqus: https://www.webrtc-experiment.com/RecordRTC/#ask
784813
785814

786-
## NPM Package
787-
788-
NPM package contains following files:
789-
790-
1. RecordRTC.js
791-
2. RecordRTC.min.js
792-
3. gif-recorder.js (for those who wanna record Gifs)
793-
4. screenshot.js (for those who wanna record Canvas2D or Webpage)
794-
5. index.html & server.js (localhost demo)
795-
796815
## License
797816

798817
[RecordRTC.js](https://github.com/muaz-khan/RecordRTC) is released under [MIT licence](https://www.webrtc-experiment.com/licence/) . Copyright (c) [Muaz Khan](http://www.MuazKhan.com).

RecordRTC.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
// Last time updated: 2016-05-06 5:21:33 PM UTC
3+
// Last time updated: 2016-05-11 3:47:57 AM UTC
44

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

@@ -37,6 +37,10 @@ function RecordRTC(mediaStream, config) {
3737
throw 'MediaStream is mandatory.';
3838
}
3939

40+
config = config || {
41+
type: 'video'
42+
};
43+
4044
config = new RecordRTCConfiguration(mediaStream, config);
4145

4246
// a reference to user's recordRTC object

RecordRTC.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "recordrtc",
3-
"version": "5.3.5",
3+
"version": "5.3.6",
44
"authors": [
55
{
66
"name": "Muaz Khan",

dev/RecordRTC.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ function RecordRTC(mediaStream, config) {
2626
throw 'MediaStream is mandatory.';
2727
}
2828

29+
config = config || {
30+
type: 'video'
31+
};
32+
2933
config = new RecordRTCConfiguration(mediaStream, config);
3034

3135
// a reference to user's recordRTC object

dev/RecordRTC.promises.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// RecordRTC.promises.js
2+
3+
// adding promises support in RecordRTC.js
4+
5+
function RecordRTCPromisesHandler(mediaStream, options) {
6+
var self = this;
7+
8+
this.recordRTC = RecordRTC(mediaStream, options);
9+
10+
this.startRecording = function() {
11+
return new Promise(function(resolve, reject) {
12+
try {
13+
self.recordRTC.startRecording();
14+
resolve();
15+
} catch (e) {
16+
reject(e);
17+
}
18+
});
19+
};
20+
21+
this.stopRecording = function() {
22+
return new Promise(function(resolve, reject) {
23+
try {
24+
self.recordRTC.stopRecording(function(url) {
25+
self.blob = self.recordRTC.blob;
26+
resolve(url);
27+
});
28+
} catch (e) {
29+
reject(e);
30+
}
31+
});
32+
};
33+
34+
this.getDataURL = function(callback) {
35+
return new Promise(function(resolve, reject) {
36+
try {
37+
self.recordRTC.getDataURL(function(dataURL) {
38+
resolve(dataURL);
39+
});
40+
} catch (e) {
41+
reject(e);
42+
}
43+
});
44+
};
45+
46+
this.getBlob = function() {
47+
return this.blob;
48+
};
49+
50+
this.blob = null;
51+
}

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
{
22
"name": "recordrtc",
33
"preferGlobal": false,
4-
"version": "5.3.5",
4+
"version": "5.3.6",
55
"author": {
66
"name": "Muaz Khan",
77
"email": "[email protected]",
88
"url": "http://www.muazkhan.com/"
99
},
1010
"description": "RecordRTC is a server-less (entire client-side) JavaScript library can be used to record WebRTC audio/video media streams. It supports cross-browser audio/video recording.",
1111
"scripts": {
12-
"start": "node RecordRTC.js"
12+
"start": "node server.js"
1313
},
14-
"main": "./RecordRTC.js",
14+
"main": "RecordRTC.js",
1515
"repository": {
1616
"type": "git",
1717
"url": "https://github.com/muaz-khan/RecordRTC.git"
@@ -37,12 +37,12 @@
3737
"_from": "recordrtc@",
3838
"devDependencies": {
3939
"grunt": "0.4.5",
40+
"grunt-bump": "0.7.0",
4041
"grunt-cli": "0.1.13",
41-
"load-grunt-tasks": "3.4.0",
4242
"grunt-contrib-concat": "0.5.1",
4343
"grunt-contrib-jshint": "0.11.3",
4444
"grunt-contrib-uglify": "0.11.0",
4545
"grunt-jsbeautifier": "0.2.10",
46-
"grunt-bump": "0.7.0"
46+
"load-grunt-tasks": "3.4.0"
4747
}
4848
}

0 commit comments

Comments
 (0)