Skip to content

Commit

Permalink
Fixed muaz-khan#56 Added "device.isCustomLabel" for empty labels.
Browse files Browse the repository at this point in the history
Removed "Please invoke getUserMedia once." Please use
"device.isCustomLabel" instead to detect if label was empty or if it is
a valid label.
  • Loading branch information
muaz-khan committed Dec 1, 2017
1 parent c94e4cc commit d2598d7
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 12 deletions.
16 changes: 14 additions & 2 deletions DetectRTC.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

// Last Updated On: 2017-11-19 2:09:51 PM UTC
// Last Updated On: 2017-12-01 1:15:48 PM UTC

// ________________
// DetectRTC v1.3.6
Expand Down Expand Up @@ -736,13 +736,25 @@
}

if (!device.label) {
device.label = 'Please invoke getUserMedia once.';
device.isCustomLabel = true;

if (device.kind === 'videoinput') {
device.label = 'Camera ' + (DetectRTC.videoInputDevices.length);
} else if (device.kind === 'audioinput') {
device.label = 'Microphone ' + (DetectRTC.audioInputDevices.length);
} else if (device.kind === 'audiooutput') {
device.label = 'Speaker ' + (DetectRTC.audioOutputDevices.length);
} else {
device.label = 'Please invoke getUserMedia once.';
}

if (typeof DetectRTC !== 'undefined' && DetectRTC.browser.isChrome && DetectRTC.browser.version >= 46 && !/^(https:|chrome-extension:)$/g.test(location.protocol || '')) {
if (typeof document !== 'undefined' && typeof document.domain === 'string' && document.domain.search && document.domain.search(/localhost|127.0./g) === -1) {
device.label = 'HTTPs is required to get label of this ' + device.kind + ' device.';
}
}
} else {
// Firefox on Android still returns empty label
if (device.kind === 'videoinput' && !isWebsiteHasWebcamPermissions) {
isWebsiteHasWebcamPermissions = true;
}
Expand Down
Loading

0 comments on commit d2598d7

Please sign in to comment.