Comparing version 1.0.0 to 1.1.0
@@ -20,2 +20,4 @@ export declare type MediaPermissionsError = { | ||
*/ | ||
export declare const requestMediaPermissions: () => Promise<boolean>; | ||
export declare const requestMediaPermissions: (constraints?: MediaStreamConstraints | undefined) => Promise<boolean>; | ||
export declare const requestAudioPermissions: () => Promise<boolean>; | ||
export declare const requestVideoPermissions: () => Promise<boolean>; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.requestMediaPermissions = exports.MediaPermissionsErrorType = void 0; | ||
exports.requestVideoPermissions = exports.requestAudioPermissions = exports.requestMediaPermissions = exports.MediaPermissionsErrorType = void 0; | ||
const bowser_1 = __importDefault(require("bowser")); | ||
@@ -24,7 +24,6 @@ var MediaPermissionsErrorType; | ||
*/ | ||
const requestMediaPermissions = () => { | ||
const requestMediaPermissions = (constraints) => { | ||
return new Promise((resolve, reject) => { | ||
let constraints = { audio: true, video: true }; | ||
navigator.mediaDevices | ||
.getUserMedia(constraints) | ||
.getUserMedia(constraints !== null && constraints !== void 0 ? constraints : { audio: true, video: true }) | ||
.then((stream) => { | ||
@@ -39,6 +38,2 @@ stream.getTracks().forEach((t) => { | ||
const browserName = browser.getBrowserName(); | ||
// console.log(browserName); | ||
// console.log(err.name); | ||
// console.log(err.message); | ||
// console.log(browser); | ||
const errName = err.name; | ||
@@ -109,1 +104,5 @@ const errMessage = err.message; | ||
exports.requestMediaPermissions = requestMediaPermissions; | ||
const requestAudioPermissions = () => (0, exports.requestMediaPermissions)({ audio: true, video: false }); | ||
exports.requestAudioPermissions = requestAudioPermissions; | ||
const requestVideoPermissions = () => (0, exports.requestMediaPermissions)({ audio: false, video: true }); | ||
exports.requestVideoPermissions = requestVideoPermissions; |
{ | ||
"name": "mic-check", | ||
"title": "mic-check", | ||
"version": "1.0.0", | ||
"description": "A wrapper for requesting audio and video permissions on websites.", | ||
"version": "1.1.0", | ||
"description": "A wrapper for requesting audio and video permissions on JavaScript websites.", | ||
"main": "lib/index.js", | ||
@@ -26,6 +26,5 @@ "module": "lib/index.js", | ||
"react", | ||
"permissions", | ||
"camera", | ||
"microphone" | ||
"permissions" | ||
], | ||
"readmeFilename": "README.md", | ||
"peerDependencies": {}, | ||
@@ -38,13 +37,3 @@ "devDependencies": { | ||
"bowser": "^2.11.0" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/gtechnologies/mic-check/issues" | ||
}, | ||
"homepage": "https://github.com/gtechnologies/mic-check#readme", | ||
"directories": { | ||
"example": "examples", | ||
"lib": "lib" | ||
}, | ||
"author": "", | ||
"license": "ISC" | ||
} | ||
} |
@@ -65,2 +65,35 @@ # mic-check | ||
## Seperate audio/video permission | ||
```ts | ||
import { | ||
MediaPermissionsError | ||
MediaPermissionsErrorType, | ||
requestAudioPermissions, | ||
requestVideoPermissions, | ||
requestMediaPermissions | ||
} from 'mic-check'; | ||
// Requesting AUDIO permission only: | ||
requestAudioPermissions() | ||
.then(() => {}) | ||
.catch((err: MediaPermissionsError) => {}); | ||
// another way to request AUDIO only... | ||
requestMediaPermissions({audio: true, video: false}) | ||
.then(() => {}) | ||
.catch((err: MediaPermissionsError) => {}); | ||
// Requesting VIDEO permission only: | ||
requestVideoPermissions() | ||
.then(() => {}) | ||
.catch((err: MediaPermissionsError) => {}); | ||
// another way to request VIDEO only... | ||
requestMediaPermissions({audio: false, video: true}) | ||
.then(() => {}) | ||
.catch((err: MediaPermissionsError) => {}); | ||
``` | ||
## Documentation | ||
@@ -103,3 +136,3 @@ | ||
<input type="checkbox" disabled /> Allow custom constraints for `getUserMedia()`. | ||
<input type="checkbox" checked /> Allow custom constraints for `getUserMedia()`. | ||
@@ -106,0 +139,0 @@ <input type="checkbox" disabled /> Handle errors for when there are no camera or microphone devices. |
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
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
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
17916
133
156
1
2
2