From 4e91222861b99faebc40b15a95f800e3ab7a1b1d Mon Sep 17 00:00:00 2001 From: Steve Seguin Date: Sun, 5 Dec 2021 01:33:24 -0500 Subject: [PATCH] rear camera on mobile mirror fix; impacts non-english mobile phones --- lib.js | 19 +++++++++++++++++++ supports.html | 25 +++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/lib.js b/lib.js index b45d6a9..e72d797 100644 --- a/lib.js +++ b/lib.js @@ -12033,6 +12033,7 @@ async function grabVideo(quality = 0, eleName = 'previewWebcam', selector = "sel } } var obscam = false; + var mirrorcheck = false; log(videoSelect.options[videoSelect.selectedIndex].text); if (videoSelect.options[videoSelect.selectedIndex].text.startsWith("OBS-Camera")) { // OBS Virtualcam mirror = true; @@ -12064,6 +12065,9 @@ async function grabVideo(quality = 0, eleName = 'previewWebcam', selector = "sel getById("cameraTipContext1").innerHTML = "Tip: A Cam Link may glitch green/purple if accessed elsewhere while already in use."; getById("cameraTip1").classList.remove("advanced"); } + } else if (session.mobile){ + mirrorcheck = true; + mirror = false; } else { mirror = false; } @@ -12088,6 +12092,21 @@ async function grabVideo(quality = 0, eleName = 'previewWebcam', selector = "sel checkBasicStreamsExist(); stream.getVideoTracks().forEach(function(track) { + + try{ + if (mirrorcheck){ + const capabilities = track.getCapabilities(); + if ("facingMode" in capabilities){ + if (capabilities.facingMode == "environment"){ + mirror=true; + session.mirrorExclude = mirror; + //applyMirror(mirror, eleName); + } + } + } + } catch(e){ + } + session.streamSrc.addTrack(track); // tracks previously removed. try{ track.onended = function(e) { // hurrah! diff --git a/supports.html b/supports.html index 78c5b65..e128913 100644 --- a/supports.html +++ b/supports.html @@ -43,8 +43,29 @@ return raw ? parseInt(raw[2], 10) : false; } - if (!getChromeVersion() || getChromeVersion < 60){ - alert("This tool really only works with recent Chromium based browsers; Firefox or Safari are not supported"); + function safariVersion() { + try { + var ver = navigator.appVersion.split("Version/"); + if (ver.length > 1) { + ver = ver[1].split(" Safari"); + } + if (ver.length > 1) { + ver = ver[0].split("."); + } + if (ver.length > 1) { + ver = parseInt(ver[0]); + } else { + ver = 0; + } + } catch (e) { + return 0; + } + return ver; + } + + + if (!((safariVersion() && safariVersion()>=15) || (getChromeVersion() || getChromeVersion >=60))){ + alert("This tool really only works with recent Chromium based browsers; Firefox is not supported: "+ safariVersion()); } function prettyPrintJsonToId(json, element) {