Skip to content

Commit

Permalink
Added recordrtc@5.3.6 Added "RecordRTCPromisesHandler"
Browse files Browse the repository at this point in the history
  • Loading branch information
muaz-khan committed May 11, 2016
1 parent 0ecec90 commit beddb4d
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 22 deletions.
43 changes: 31 additions & 12 deletions README.md
Expand Up @@ -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?
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -783,16 +812,6 @@ The domain www.RecordRTC.org is open-sourced here:
* Disqus: https://www.webrtc-experiment.com/RecordRTC/#ask
* Email: muazkh@gmail.com

## 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).
6 changes: 5 additions & 1 deletion RecordRTC.js
@@ -1,6 +1,6 @@
'use strict';

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

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

Expand Down Expand Up @@ -37,6 +37,10 @@ function RecordRTC(mediaStream, config) {
throw 'MediaStream is mandatory.';
}

config = config || {
type: 'video'
};

config = new RecordRTCConfiguration(mediaStream, config);

// a reference to user's recordRTC object
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.3.5",
"version": "5.3.6",
"authors": [
{
"name": "Muaz Khan",
Expand Down
4 changes: 4 additions & 0 deletions dev/RecordRTC.js
Expand Up @@ -26,6 +26,10 @@ function RecordRTC(mediaStream, config) {
throw 'MediaStream is mandatory.';
}

config = config || {
type: 'video'
};

config = new RecordRTCConfiguration(mediaStream, config);

// a reference to user's recordRTC object
Expand Down
51 changes: 51 additions & 0 deletions dev/RecordRTC.promises.js
@@ -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;
}
10 changes: 5 additions & 5 deletions package.json
@@ -1,17 +1,17 @@
{
"name": "recordrtc",
"preferGlobal": false,
"version": "5.3.5",
"version": "5.3.6",
"author": {
"name": "Muaz Khan",
"email": "muazkh@gmail.com",
"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"
Expand All @@ -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"
}
}

0 comments on commit beddb4d

Please sign in to comment.