Skip to content

Commit

Permalink
semantic version bump to 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianLi101 committed Oct 1, 2021
1 parent e8d06a3 commit 6a4a898
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
6 changes: 4 additions & 2 deletions lib/requestMediaPermissions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export declare enum MediaPermissionsErrorType {
Generic = "Generic"
}
/**
* Here's some documentation
* Request camera and mic permissions from the browser.
* @returns
*/
export declare const requestMediaPermissions: () => Promise<unknown>;
export declare const requestMediaPermissions: (constraints?: MediaStreamConstraints | undefined) => Promise<boolean>;
export declare const requestAudioPermissions: () => Promise<boolean>;
export declare const requestVideoPermissions: () => Promise<boolean>;
17 changes: 8 additions & 9 deletions lib/requestMediaPermissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
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"));
var MediaPermissionsErrorType;
(function (MediaPermissionsErrorType) {
Expand All @@ -17,14 +17,13 @@ var MediaPermissionsErrorType;
MediaPermissionsErrorType["Generic"] = "Generic";
})(MediaPermissionsErrorType = exports.MediaPermissionsErrorType || (exports.MediaPermissionsErrorType = {}));
/**
* Here's some documentation
* Request camera and mic permissions from the browser.
* @returns
*/
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) => {
stream.getTracks().forEach((t) => {
t.stop();
Expand All @@ -34,10 +33,6 @@ const requestMediaPermissions = () => {
.catch((err) => {
const browser = bowser_1.default.getParser(window.navigator.userAgent);
const browserName = browser.getBrowserName();
console.log(browserName);
console.log(err.name);
console.log(err.message);
console.log(browser);
const errName = err.name;
const errMessage = err.message;
let errorType = MediaPermissionsErrorType.Generic;
Expand Down Expand Up @@ -103,3 +98,7 @@ const requestMediaPermissions = () => {
});
};
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;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mic-check",
"title": "mic-check",
"version": "1.0.1",
"version": "1.1.0",
"description": "A wrapper for requesting audio and video permissions on JavaScript websites.",
"main": "lib/index.js",
"module": "lib/index.js",
Expand Down

0 comments on commit 6a4a898

Please sign in to comment.