forked from muaz-khan/RecordRTC
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added [email protected] Added "RecordRTCPromisesHandler"
- Loading branch information
Showing
7 changed files
with
100 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,8 +136,8 @@ bower install recordrtc | |
You can even link specific [releases](https://github.com/muaz-khan/RecordRTC/releases): | ||
|
||
```html | ||
<!-- use 5.3.5 or any other version --> | ||
<script src="https://github.com/muaz-khan/RecordRTC/releases/download/5.3.5/RecordRTC.js"></script> | ||
<!-- use 5.3.6 or any other version --> | ||
<script src="https://github.com/muaz-khan/RecordRTC/releases/download/5.3.6/RecordRTC.js"></script> | ||
``` | ||
|
||
## How to capture stream? | ||
|
@@ -756,6 +756,35 @@ recordRTC.getFromDisk(function(dataURL) { | |
|
||
In the above example; you can see that `recordRTC` instance object is used instead of global `RecordRTC` object. | ||
|
||
## Promises | ||
|
||
```html | ||
<script src="https://cdn.WebRTC-Experiment.com/RecordRTC.js"></script> | ||
|
||
<!-- link this file as well --> | ||
<script src="/dev/RecordRTC.promises.js"></script> | ||
|
||
<script> | ||
// use "RecordRTCPromisesHandler" instead of "RecordRTC" | ||
var recorder = new RecordRTCPromisesHandler(mediaStream, options); | ||
recorder.startRecording().then(function() { | ||
}).catch(function(error) { | ||
// | ||
}); | ||
recorder.stopRecording().then(function(url) { | ||
var blob = recorder.blob; | ||
recorder.getDataURL().then(function(dataURL) { | ||
// | ||
}).catch(function(error) {}) | ||
}).catch(function(error) { | ||
// | ||
}); | ||
</script> | ||
``` | ||
|
||
## Credits | ||
|
||
1. [Recorderjs](https://github.com/mattdiamond/Recorderjs) for audio recording | ||
|
@@ -783,16 +812,6 @@ The domain www.RecordRTC.org is open-sourced here: | |
* Disqus: https://www.webrtc-experiment.com/RecordRTC/#ask | ||
* Email: [email protected] | ||
|
||
## NPM Package | ||
|
||
NPM package contains following files: | ||
|
||
1. RecordRTC.js | ||
2. RecordRTC.min.js | ||
3. gif-recorder.js (for those who wanna record Gifs) | ||
4. screenshot.js (for those who wanna record Canvas2D or Webpage) | ||
5. index.html & server.js (localhost demo) | ||
|
||
## License | ||
|
||
[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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "recordrtc", | ||
"version": "5.3.5", | ||
"version": "5.3.6", | ||
"authors": [ | ||
{ | ||
"name": "Muaz Khan", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// RecordRTC.promises.js | ||
|
||
// adding promises support in RecordRTC.js | ||
|
||
function RecordRTCPromisesHandler(mediaStream, options) { | ||
var self = this; | ||
|
||
this.recordRTC = RecordRTC(mediaStream, options); | ||
|
||
this.startRecording = function() { | ||
return new Promise(function(resolve, reject) { | ||
try { | ||
self.recordRTC.startRecording(); | ||
resolve(); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
}); | ||
}; | ||
|
||
this.stopRecording = function() { | ||
return new Promise(function(resolve, reject) { | ||
try { | ||
self.recordRTC.stopRecording(function(url) { | ||
self.blob = self.recordRTC.blob; | ||
resolve(url); | ||
}); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
}); | ||
}; | ||
|
||
this.getDataURL = function(callback) { | ||
return new Promise(function(resolve, reject) { | ||
try { | ||
self.recordRTC.getDataURL(function(dataURL) { | ||
resolve(dataURL); | ||
}); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
}); | ||
}; | ||
|
||
this.getBlob = function() { | ||
return this.blob; | ||
}; | ||
|
||
this.blob = null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
{ | ||
"name": "recordrtc", | ||
"preferGlobal": false, | ||
"version": "5.3.5", | ||
"version": "5.3.6", | ||
"author": { | ||
"name": "Muaz Khan", | ||
"email": "[email protected]", | ||
"url": "http://www.muazkhan.com/" | ||
}, | ||
"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.", | ||
"scripts": { | ||
"start": "node RecordRTC.js" | ||
"start": "node server.js" | ||
}, | ||
"main": "./RecordRTC.js", | ||
"main": "RecordRTC.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/muaz-khan/RecordRTC.git" | ||
|
@@ -37,12 +37,12 @@ | |
"_from": "recordrtc@", | ||
"devDependencies": { | ||
"grunt": "0.4.5", | ||
"grunt-bump": "0.7.0", | ||
"grunt-cli": "0.1.13", | ||
"load-grunt-tasks": "3.4.0", | ||
"grunt-contrib-concat": "0.5.1", | ||
"grunt-contrib-jshint": "0.11.3", | ||
"grunt-contrib-uglify": "0.11.0", | ||
"grunt-jsbeautifier": "0.2.10", | ||
"grunt-bump": "0.7.0" | ||
"load-grunt-tasks": "3.4.0" | ||
} | ||
} |