Skip to content

Commit

Permalink
Fixed DetectRTC captureStream detection.
Browse files Browse the repository at this point in the history
  • Loading branch information
muaz-khan committed Nov 12, 2016
1 parent 65a450d commit bf1ad7f
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 6 deletions.
12 changes: 11 additions & 1 deletion DetectRTC.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Last time updated: 2016-11-02 8:56:06 AM UTC
// Last time updated: 2016-11-12 6:02:08 AM UTC

// Latest file can be found here: https://cdn.webrtc-experiment.com/DetectRTC.js

Expand Down Expand Up @@ -894,6 +894,16 @@
DetectRTC.isCanvasSupportsStreamCapturing = isCanvasSupportsStreamCapturing;
DetectRTC.isVideoSupportsStreamCapturing = isVideoSupportsStreamCapturing;

if (DetectRTC.browser.name == 'Chrome' && DetectRTC.browser.version >= 53) {
if (!DetectRTC.isCanvasSupportsStreamCapturing) {
DetectRTC.isCanvasSupportsStreamCapturing = 'Requires chrome flag: enable-experimental-web-platform-features';
}

if (!DetectRTC.isVideoSupportsStreamCapturing) {
DetectRTC.isVideoSupportsStreamCapturing = 'Requires chrome flag: enable-experimental-web-platform-features';
}
}

// ------
DetectRTC.DetectLocalIPAddress = DetectLocalIPAddress;

Expand Down
4 changes: 2 additions & 2 deletions DetectRTC.min.js

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions dev/DetectRTC.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ DetectRTC.displayResolution = displayResolution;
DetectRTC.isCanvasSupportsStreamCapturing = isCanvasSupportsStreamCapturing;
DetectRTC.isVideoSupportsStreamCapturing = isVideoSupportsStreamCapturing;

if (DetectRTC.browser.name == 'Chrome' && DetectRTC.browser.version >= 53) {
if (!DetectRTC.isCanvasSupportsStreamCapturing) {
DetectRTC.isCanvasSupportsStreamCapturing = 'Requires chrome flag: enable-experimental-web-platform-features';
}

if (!DetectRTC.isVideoSupportsStreamCapturing) {
DetectRTC.isVideoSupportsStreamCapturing = 'Requires chrome flag: enable-experimental-web-platform-features';
}
}

// ------
DetectRTC.DetectLocalIPAddress = DetectLocalIPAddress;

Expand Down
27 changes: 24 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ <h2 id="welcome">DetectRTC!</h2>
return tr;
}

window.onerror = console.error = function() {
appendTR('Error', JSON.stringify(arguments), 'error');
};

function printVal(value) {
return value == true ? 'Yep' : value == false ? 'Nope' : value;
}
Expand Down Expand Up @@ -329,10 +333,27 @@ <h2 id="welcome">DetectRTC!</h2>
DetectRTC.load(function() {
reloadDetectRTC();

if(DetectRTC.MediaDevices[0] && DetectRTC.MediaDevices[0].label === 'Please invoke getUserMedia once.') {
navigator.mediaDevices.getUserMedia({audio: true, video: true}).then(reloadDetectRTC).catch(reloadDetectRTC);
return;
try {
if(DetectRTC.MediaDevices[0] && DetectRTC.MediaDevices[0].label === 'Please invoke getUserMedia once.') {
navigator.mediaDevices.getUserMedia({audio: true, video: true}).then(function(stream) {
reloadDetectRTC();

try {
// release camera
stream.getVideoTracks().forEach(function(track) {
track.stop();
});

stream.getAudioTracks().forEach(function(track) {
track.stop();
});
}
catch(e) {}
}).catch(reloadDetectRTC);
return;
}
}
catch(e) {}

onDetectRTCLoaded();
});
Expand Down

0 comments on commit bf1ad7f

Please sign in to comment.