getscreenmedia
Advanced tools
Comparing version 1.4.0 to 1.5.0
@@ -26,3 +26,3 @@ !function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):"undefined"!=typeof window?window.getScreenMedia=e():"undefined"!=typeof global?global.getScreenMedia=e():"undefined"!=typeof self&&(self.getScreenMedia=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(require,module,exports){ | ||
// check that the extension is installed by looking for a | ||
// check that the extension is installed by looking for a | ||
// sessionStorage variable that contains the extension id | ||
@@ -40,3 +40,3 @@ // this has to be set after installation unless the contest | ||
} else { | ||
var constraints = constraints || {audio: false, video: { | ||
constraints = (hasConstraints && constraints) || {audio: false, video: { | ||
mandatory: { | ||
@@ -58,2 +58,26 @@ chromeMediaSource: 'desktop', | ||
); | ||
} else if (window.cefGetScreenMedia) { | ||
//window.cefGetScreenMedia is experimental - may be removed without notice | ||
window.cefGetScreenMedia(function(sourceId) { | ||
if (!sourceId) { | ||
var error = new Error('cefGetScreenMediaError'); | ||
error.name = 'CEF_GETSCREENMEDIA_CANCELED'; | ||
callback(error); | ||
} else { | ||
constraints = (hasConstraints && constraints) || {audio: false, video: { | ||
mandatory: { | ||
chromeMediaSource: 'desktop', | ||
maxWidth: window.screen.width, | ||
maxHeight: window.screen.height, | ||
maxFrameRate: 3 | ||
}, | ||
optional: [ | ||
{googLeakyBucket: true}, | ||
{googTemporalLayeredScreencast: true} | ||
] | ||
}}; | ||
constraints.video.mandatory.chromeMediaSourceId = sourceId; | ||
getUserMedia(constraints, callback); | ||
} | ||
}); | ||
} else if (isCef || (chromever >= 26 && chromever <= maxver)) { | ||
@@ -164,3 +188,5 @@ // chrome 26 - chrome 33 way to do it -- requires bad chrome://flags | ||
var defaultOpts = {video: true, audio: true}; | ||
var denied = 'PermissionDeniedError'; | ||
var altDenied = 'PERMISSION_DENIED'; | ||
var notSatisfied = 'ConstraintNotSatisfiedError'; | ||
@@ -186,15 +212,2 @@ | ||
// make requesting media from non-http sources trigger an error | ||
// current browsers silently drop the request instead | ||
var protocol = window.location.protocol; | ||
if (protocol !== 'http:' && protocol !== 'https:') { | ||
error = new Error('MediaStreamError'); | ||
error.name = 'NotSupportedError'; | ||
// keep all callbacks async | ||
return window.setTimeout(function () { | ||
cb(error); | ||
}, 0); | ||
} | ||
// normalize error handling when no media types are requested | ||
@@ -224,3 +237,3 @@ if (!constraints.audio && !constraints.video) { | ||
error = new Error('MediaStreamError'); | ||
if (err === denied) { | ||
if (err === denied || err === altDenied) { | ||
error.name = denied; | ||
@@ -227,0 +240,0 @@ } else { |
@@ -25,3 +25,3 @@ // getScreenMedia helper by @HenrikJoreteg | ||
// check that the extension is installed by looking for a | ||
// check that the extension is installed by looking for a | ||
// sessionStorage variable that contains the extension id | ||
@@ -39,3 +39,3 @@ // this has to be set after installation unless the contest | ||
} else { | ||
var constraints = constraints || {audio: false, video: { | ||
constraints = (hasConstraints && constraints) || {audio: false, video: { | ||
mandatory: { | ||
@@ -57,2 +57,26 @@ chromeMediaSource: 'desktop', | ||
); | ||
} else if (window.cefGetScreenMedia) { | ||
//window.cefGetScreenMedia is experimental - may be removed without notice | ||
window.cefGetScreenMedia(function(sourceId) { | ||
if (!sourceId) { | ||
var error = new Error('cefGetScreenMediaError'); | ||
error.name = 'CEF_GETSCREENMEDIA_CANCELED'; | ||
callback(error); | ||
} else { | ||
constraints = (hasConstraints && constraints) || {audio: false, video: { | ||
mandatory: { | ||
chromeMediaSource: 'desktop', | ||
maxWidth: window.screen.width, | ||
maxHeight: window.screen.height, | ||
maxFrameRate: 3 | ||
}, | ||
optional: [ | ||
{googLeakyBucket: true}, | ||
{googTemporalLayeredScreencast: true} | ||
] | ||
}}; | ||
constraints.video.mandatory.chromeMediaSourceId = sourceId; | ||
getUserMedia(constraints, callback); | ||
} | ||
}); | ||
} else if (isCef || (chromever >= 26 && chromever <= maxver)) { | ||
@@ -59,0 +83,0 @@ // chrome 26 - chrome 33 way to do it -- requires bad chrome://flags |
{ | ||
"name": "getscreenmedia", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "A browser module for attempting to get access to a MediaStream of a user's screen. With a nice node-like API.", | ||
@@ -5,0 +5,0 @@ "main": "getscreenmedia.js", |
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
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
26304
13
489
1