getusermedia
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -31,2 +31,6 @@ !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){ | ||
if (localStorage && localStorage.useFirefoxFakeDevice === "true") { | ||
constraints.fake = true; | ||
} | ||
func.call(window.navigator, constraints, function (stream) { | ||
@@ -33,0 +37,0 @@ cb(null, stream); |
@@ -30,2 +30,6 @@ // getUserMedia helper by @HenrikJoreteg | ||
if (localStorage && localStorage.useFirefoxFakeDevice === "true") { | ||
constraints.fake = true; | ||
} | ||
func.call(window.navigator, constraints, function (stream) { | ||
@@ -32,0 +36,0 @@ cb(null, stream); |
{ | ||
"name": "getusermedia", | ||
"description": "cross-browser getUserMedia shim with node.js style error-first API.", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"author": "Henrik Joreteg <henrik@andyet.net>", | ||
@@ -6,0 +6,0 @@ "browser": "index-browser.js", |
@@ -87,27 +87,8 @@ # getUserMedia | ||
All failed calls to `getusermedia` in this library will return an error object (of type `NavigatorUserMediaError`) as the first argument to the callback. All will have a `.name` attribute of one of the following strings. | ||
All failed calls to `getusermedia` in this library will return an error object (of type `NavigatorUserMediaError`) as the first argument to the callback. All will have a `.name` according to [the specification](http://w3c.github.io/mediacapture-main/getusermedia.html#mediastreamerror) | ||
- `"NOT_SUPPORTED"` (for cases where a browser doesn't support `getUserMedia`.) | ||
- `"PERMISSION_DENIED"` | ||
- `"CONSTRAINT_NOT_SATISFIED"` | ||
## Testing | ||
For Firefox testing, the module evaluates the localStorage 'useFirefoxFakeDevice' variable to access fake devices. | ||
## More about errors | ||
As of this writing all browsers handle errors differently. Firefox calls the error callback with a string, Chrome with an error object. | ||
Neither follow [the spec](http://dev.w3.org/2011/webrtc/editor/getusermedia.html#navigatorusermediaerror-and-navigatorusermediaerrorcallback) which says it should be an error object with an appropriate `.name` attribute. | ||
According to the spec all errors should be an error object of type `NavigatorUserMediaError`. With a `.name` attribute of either: | ||
- `"PERMISSION_DENIED"` | ||
- `"CONSTRAINT_NOT_SATISFIED"` | ||
Also, it sucks to have to test for capability before calling getUserMedia. This lib solves that too. So you still get an appropriate error object back with a `.name` of `"NOT_SUPPORTED_ERROR"` which is the same as what the spec says to do if a constraint is requested but not supported. For example requesting video/audio when you only have a microphone in a browser that still supports `getUserMedia`. | ||
In this library we add one more: | ||
- `"NOT_SUPPORTED"` for cases where a browser doesn't support `getUserMedia`. | ||
## License | ||
@@ -114,0 +95,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
139
0
9922
101