From 4749fe3bbf1848262f5ad3fb5b1b6b9ae0a1d37d Mon Sep 17 00:00:00 2001 From: steveseguin Date: Sat, 5 Aug 2023 09:13:25 -0400 Subject: [PATCH] fix issue where undefined crashes pip2 --- index.html | 4 ++-- lib.js | 21 ++++++++++++++++++++- main.js | 2 +- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 015feb4..1529727 100644 --- a/index.html +++ b/index.html @@ -2641,11 +2641,11 @@ // session.hidehome = true; // If used, 'hide home' will make the landing page inaccessible, along with hiding a few go-home elements. // session.record = false; // uncomment to block users from being able to record via vdo.ninja's built in recording function - + - + diff --git a/lib.js b/lib.js index c91752d..06fc0b8 100644 --- a/lib.js +++ b/lib.js @@ -7266,6 +7266,16 @@ function applyEffects(track) { // video only please. do not touch audio. Run up } else { session.canvasSource.onloadeddata = mainMeshMask; } + } else if (session.effect == "13"){ // ha, no way to turn it off once it's started, except to change cameras? not sure. + try { + track.applyConstraints({backgroundBlur: true}).then(() => { + const settings = track.getSettings(); + log(`Background blur is ${settings.backgroundBlur ? "ON" : "OFF"}`); + }).catch(errorlog); + } catch(e){ + errorlog(e); + } + return track; } else { if (session.canvasource){ session.canvasSource.srcObject.getVideoTracks().forEach(function(trk) { @@ -22299,6 +22309,15 @@ async function grabVideo(quality = 0, eleName = 'previewWebcam', selector = "sel session.mirrorExclude = true; } } + if ("backgroundBlur" in capabilities){ // Chrome original trial, until v117, and then??? + query('#effectSelector option[value="13"]').classList.remove("hidden"); + query('#effectSelector option[value="13"]').disabled = null; + query('#effectSelector3 option[value="13"]').classList.remove("hidden"); + query('#effectSelector3 option[value="13"]').disabled = null; + } else { + query('#effectSelector option[value="13"]').disabled = true; + query('#effectSelector3 option[value="13"]').disabled = true; + } } } catch(e){} @@ -30197,7 +30216,7 @@ function fullscreenPageToggle(state=null){ session.pipWindow = false; async function PictureInPicturePageToggle(state=null){ try { - if (!documentPictureInPicture){return;} + if (typeof documentPictureInPicture === "undefined"){return;} if (session.pipWindow){ getById("testtone").parentNode.insertBefore(session.pipWindow.document.getElementById("gridlayout"), getById("testtone")); session.pipWindow.close(); diff --git a/main.js b/main.js index 8763416..558c69e 100644 --- a/main.js +++ b/main.js @@ -841,7 +841,7 @@ async function main(){ // main asyncronous thread; mostly initializes the user s } if (urlParams.has('pip2') || urlParams.has('pipall')){ // just an alternative; might be compoundable - if (documentPictureInPicture){ + if (typeof documentPictureInPicture !== "undefined"){ getById("PictureInPicturePage").classList.remove("hidden"); } }