Skip to content

Commit

Permalink
Added msr@1.3.0 Now supporting AMD+NPM packages
Browse files Browse the repository at this point in the history
  • Loading branch information
muaz-khan committed May 5, 2016
1 parent 92c42a1 commit bebc368
Show file tree
Hide file tree
Showing 21 changed files with 353 additions and 34 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ node_modules

# bower
bower_components

npm-debug.log
4 changes: 3 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
node_modules
lib-cov
npm-debug.log
npm-debug.log

bower_components
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ node_js:
- "0.11"
install: npm install
before_script:
- npm install grunt-cli
- npm install grunt
- npm install grunt-cli@0.1.13 -g
- npm install grunt@0.4.5
- grunt
after_failure: npm install && grunt
matrix:
fast_finish: true
4 changes: 4 additions & 0 deletions AudioStreamRecorder/MediaRecorderWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,7 @@ function MediaRecorderWrapper(mediaStream) {
setTimeout(looper, 1000); // check every second
})();
}

if (typeof MediaStreamRecorder !== 'undefined') {
MediaStreamRecorder.MediaRecorderWrapper = MediaRecorderWrapper;
}
4 changes: 4 additions & 0 deletions AudioStreamRecorder/StereoAudioRecorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ function StereoAudioRecorder(mediaStream) {
var mediaRecorder;
var timeout;
}

if (typeof MediaStreamRecorder !== 'undefined') {
MediaStreamRecorder.StereoAudioRecorder = StereoAudioRecorder;
}
4 changes: 4 additions & 0 deletions AudioStreamRecorder/StereoAudioRecorderHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,7 @@ function StereoAudioRecorderHelper(mediaStream, root) {
volume.connect(scriptprocessornode);
scriptprocessornode.connect(context.destination);
}

if (typeof MediaStreamRecorder !== 'undefined') {
MediaStreamRecorder.StereoAudioRecorderHelper = StereoAudioRecorderHelper;
}
3 changes: 2 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ module.exports = function(grunt) {
'VideoStreamRecorder/WhammyRecorder.js',
'VideoStreamRecorder/WhammyRecorderHelper.js',
'VideoStreamRecorder/GifRecorder.js',
'VideoStreamRecorder/lib/whammy.js'
'VideoStreamRecorder/lib/whammy.js',
'common/amd.js'
],
dest: 'MediaStreamRecorder.js'
},
Expand Down
112 changes: 108 additions & 4 deletions MediaStreamRecorder.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Last time updated: 2016-04-15 12:50:55 PM UTC
// Last time updated: 2016-05-05 5:44:00 AM UTC

// links:
// Open-Sourced: https://github.com/streamproc/MediaStreamRecorder
Expand Down Expand Up @@ -257,9 +257,74 @@ function MultiStreamRecorder(mediaStream) {
var recordingInterval = 0;
}

if (typeof MediaStreamRecorder !== 'undefined') {
MediaStreamRecorder.MultiStreamRecorder = MultiStreamRecorder;
}

// _____________________________
// Cross-Browser-Declarations.js

var browserFakeUserAgent = 'Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45';

(function(that) {
if (typeof window !== 'undefined') {
return;
}

if (typeof window === 'undefined' && typeof global !== 'undefined') {
global.navigator = {
userAgent: browserFakeUserAgent,
getUserMedia: function() {}
};

/*global window:true */
that.window = global;
} else if (typeof window === 'undefined') {
// window = this;
}

if (typeof document === 'undefined') {
/*global document:true */
that.document = {};

document.createElement = document.captureStream = document.mozCaptureStream = function() {
return {};
};
}

if (typeof location === 'undefined') {
/*global location:true */
that.location = {
protocol: 'file:',
href: '',
hash: ''
};
}

if (typeof screen === 'undefined') {
/*global screen:true */
that.screen = {
width: 0,
height: 0
};
}
})(typeof global !== 'undefined' ? global : window);

// WebAudio API representer
var AudioContext = window.AudioContext;

if (typeof AudioContext === 'undefined') {
if (typeof webkitAudioContext !== 'undefined') {
/*global AudioContext:true */
AudioContext = webkitAudioContext;
}

if (typeof mozAudioContext !== 'undefined') {
/*global AudioContext:true */
AudioContext = mozAudioContext;
}
}

if (typeof window === 'undefined') {
/*jshint -W020 */
window = {};
Expand Down Expand Up @@ -297,9 +362,9 @@ if (typeof navigator !== 'undefined') {
navigator.getUserMedia = navigator.mozGetUserMedia;
}
} else {
/*global navigator:true */
var navigator = {
getUserMedia: {}
navigator = {
getUserMedia: function() {},
userAgent: browserFakeUserAgent
};
}

Expand Down Expand Up @@ -789,6 +854,10 @@ function MediaRecorderWrapper(mediaStream) {
})();
}

if (typeof MediaStreamRecorder !== 'undefined') {
MediaStreamRecorder.MediaRecorderWrapper = MediaRecorderWrapper;
}

// ======================
// StereoAudioRecorder.js

Expand Down Expand Up @@ -837,6 +906,10 @@ function StereoAudioRecorder(mediaStream) {
var timeout;
}

if (typeof MediaStreamRecorder !== 'undefined') {
MediaStreamRecorder.StereoAudioRecorder = StereoAudioRecorder;
}

// ============================
// StereoAudioRecorderHelper.js

Expand Down Expand Up @@ -1068,6 +1141,10 @@ function StereoAudioRecorderHelper(mediaStream, root) {
scriptprocessornode.connect(context.destination);
}

if (typeof MediaStreamRecorder !== 'undefined') {
MediaStreamRecorder.StereoAudioRecorderHelper = StereoAudioRecorderHelper;
}

// ===================
// WhammyRecorder.js

Expand Down Expand Up @@ -1128,6 +1205,10 @@ function WhammyRecorder(mediaStream) {
var timeout;
}

if (typeof MediaStreamRecorder !== 'undefined') {
MediaStreamRecorder.WhammyRecorder = WhammyRecorder;
}

// ==========================
// WhammyRecorderHelper.js

Expand Down Expand Up @@ -1425,6 +1506,10 @@ function WhammyRecorderHelper(mediaStream, root) {
};
}

if (typeof MediaStreamRecorder !== 'undefined') {
MediaStreamRecorder.WhammyRecorderHelper = WhammyRecorderHelper;
}

// --------------
// GifRecorder.js

Expand Down Expand Up @@ -1561,6 +1646,10 @@ function GifRecorder(mediaStream) {
var timeout;
}

if (typeof MediaStreamRecorder !== 'undefined') {
MediaStreamRecorder.GifRecorder = GifRecorder;
}

// https://github.com/antimatter15/whammy/blob/master/LICENSE
// _________
// Whammy.js
Expand Down Expand Up @@ -1994,3 +2083,18 @@ var Whammy = (function() {
Video: WhammyVideo
};
})();

if (typeof MediaStreamRecorder !== 'undefined') {
MediaStreamRecorder.Whammy = Whammy;
}

// https://github.com/streamproc/MediaStreamRecorder/issues/42
if (typeof module !== 'undefined' /* && !!module.exports*/ ) {
module.exports = MediaStreamRecorder;
}

if (typeof define === 'function' && define.amd) {
define('MediaStreamRecorder', [], function() {
return MediaStreamRecorder;
});
}
4 changes: 2 additions & 2 deletions MediaStreamRecorder.min.js

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,48 @@ You can [install scripts using NPM](https://www.npmjs.org/package/msr):

```javascript
npm install msr

# or via "bower"
bower install msr
```

Now try `node server.js` and open `https://localhost:9001/`

# Test on NPM

```javascript
var MediaStreamRecorder = require('msr');

console.log('require-msr', MediaStreamRecorder);

console.log('\n\n-------\n\n');

var recorder = new MediaStreamRecorder({});
console.log('MediaStreamRecorder', recorder);

console.log('\n\n-------\n\n');

var multiStreamRecorder = new MediaStreamRecorder.MultiStreamRecorder({});
console.log('MultiStreamRecorder', multiStreamRecorder);
```

* Live NPM test: https://tonicdev.com/npm/msr

Or try `npm-test.js`:

```
cd node_modules
cd msr
node npm-test.js
```

Then link single/standalone "MediaStreamRecorder.js" file:

```html
<script src="./node_modules/msr/MediaStreamRecorder.js"> </script>

<!-- or bower -->
<script src="./bower_components/msr/MediaStreamRecorder.js"></script>
```

## Otherwise, you can "directly" link standalone file from CDN:
Expand Down
4 changes: 4 additions & 0 deletions VideoStreamRecorder/GifRecorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,7 @@ function GifRecorder(mediaStream) {
var gifEncoder;
var timeout;
}

if (typeof MediaStreamRecorder !== 'undefined') {
MediaStreamRecorder.GifRecorder = GifRecorder;
}
4 changes: 4 additions & 0 deletions VideoStreamRecorder/WhammyRecorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,7 @@ function WhammyRecorder(mediaStream) {
var mediaRecorder;
var timeout;
}

if (typeof MediaStreamRecorder !== 'undefined') {
MediaStreamRecorder.WhammyRecorder = WhammyRecorder;
}
4 changes: 4 additions & 0 deletions VideoStreamRecorder/WhammyRecorderHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,3 +294,7 @@ function WhammyRecorderHelper(mediaStream, root) {
isPaused = false;
};
}

if (typeof MediaStreamRecorder !== 'undefined') {
MediaStreamRecorder.WhammyRecorderHelper = WhammyRecorderHelper;
}
4 changes: 3 additions & 1 deletion VideoStreamRecorder/lib/gif-encoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -1342,4 +1342,6 @@ GIFEncoder = function() {

};


if(typeof MediaStreamRecorder !== 'undefined') {
MediaStreamRecorder.GIFEncoder = GIFEncoder;
}
4 changes: 4 additions & 0 deletions VideoStreamRecorder/lib/whammy.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,3 +431,7 @@ var Whammy = (function() {
Video: WhammyVideo
};
})();

if (typeof MediaStreamRecorder !== 'undefined') {
MediaStreamRecorder.Whammy = Whammy;
}
69 changes: 69 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"name": "msr",
"version": "1.3.0",
"authors": [
{
"name": "Muaz Khan",
"email": "muazkh@gmail.com",
"homepage": "http://www.muazkhan.com/"
}
],
"homepage": "https://github.com/streamproc/MediaStreamRecorder",
"repository": {
"type": "git",
"url": "https://github.com/streamproc/MediaStreamRecorder.git"
},
"description": "Cross-Browser recording of audio/video media streams; targets WebRTC/getUserMedia/WebAudio/etc. Works both on Chrome/Firefox/Opera on desktop & android.",
"main": "MediaStreamRecorder.js",
"keywords": [
"recorder",
"audio-recorder",
"video-recorder",
"audio-recording",
"video-recording",
"recording",
"record",
"audio-video-recorder",
"gif-recorder",
"audio",
"video",
"gif",
"mediarecorder",
"media",
"client-side",
"webrtc",
"mediastreamrecorder",
"webrtc-library",
"library",
"javascript",
"chrome",
"firefox",
"opera",
"mediastreamrecorder.js",
"webrtc-experiment",
"javascript-library",
"muaz",
"muaz-khan",
"stereorecorder",
"mediarecorder",
"whammyrecorder",
"gifrecorder",
"multistreamrecorder"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules"
],
"devDependencies": {
"grunt": "0.4.5",
"grunt-cli": "0.1.13",
"load-grunt-tasks": "3.2.0",
"grunt-contrib-concat": "0.5.1",
"grunt-contrib-csslint": "0.4.0",
"grunt-contrib-uglify": "0.9.1",
"grunt-htmlhint": "0.4.1",
"grunt-jsbeautifier": "0.2.10",
"grunt-bump": "0.3.1"
}
}
Loading

0 comments on commit bebc368

Please sign in to comment.