forked from otalk/getUserMedia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetusermedia.bundle.js
71 lines (63 loc) · 2.95 KB
/
getusermedia.bundle.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.getUserMedia=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
// getUserMedia helper by @HenrikJoreteg
var func = (window.navigator.getUserMedia ||
window.navigator.webkitGetUserMedia ||
window.navigator.mozGetUserMedia ||
window.navigator.msGetUserMedia);
module.exports = function (constraints, cb) {
var options;
var haveOpts = arguments.length === 2;
var defaultOpts = {video: true, audio: true};
var error;
var denied = 'PermissionDeniedError';
var notSatified = 'ConstraintNotSatisfiedError';
// make constraints optional
if (!haveOpts) {
cb = constraints;
constraints = defaultOpts;
}
// treat lack of browser support like an error
if (!func) {
// throw proper error per spec
error = new Error('MediaStreamError');
error.name = 'NotSupportedError';
return cb(error);
}
if (localStorage && localStorage.useFirefoxFakeDevice === "true") {
constraints.fake = true;
}
func.call(window.navigator, constraints, function (stream) {
cb(null, stream);
}, function (err) {
var error;
// coerce into an error object since FF gives us a string
// there are only two valid names according to the spec
// we coerce all non-denied to "constraint not satisfied".
if (typeof err === 'string') {
error = new Error('MediaStreamError');
if (err === denied) {
error.name = denied;
} else {
error.name = notSatified;
}
} else {
// if we get an error object make sure '.name' property is set
// according to spec: http://dev.w3.org/2011/webrtc/editor/getusermedia.html#navigatorusermediaerror-and-navigatorusermediaerrorcallback
error = err;
if (!error.name) {
// this is likely chrome which
// sets a property called "ERROR_DENIED" on the error object
// if so we make sure to set a name
if (error[denied]) {
err.name = denied;
} else {
err.name = notSatified;
}
}
}
cb(error);
});
};
},{}]},{},[1])
(1)
});