bug fixes mainly

This commit is contained in:
steveseguin 2023-03-25 23:02:27 -04:00
parent 43e577d25e
commit b246baf455
5 changed files with 126 additions and 38 deletions

View File

@ -83,7 +83,7 @@
<script type="text/javascript" crossorigin="anonymous" src="./thirdparty/CodecsHandler.js?ver=45"></script>
<script type="text/javascript" crossorigin="anonymous" src="./thirdparty/aes.js"></script>
<script type="text/javascript" crossorigin="anonymous" src="./webrtc.js?ver=587"></script>
<script type="text/javascript" crossorigin="anonymous" src="./webrtc.js?ver=589"></script>
<input id="zoomSlider" type="range" style="display: none;" />
<span id="electronDragZone" style="pointer-events: none; z-index:-10; position:absolute;top:0;left:0;width:100%;height:2%;-webkit-app-region: drag;min-height:20px;"></span>
<div id="header">
@ -1993,6 +1993,19 @@
<span data-translate="stop-record-to-disk">Stop Recording</span>
</a>
</li>
<li class="context-menu__item hidden">
<a href="#" class="context-menu__link" data-action="CopyFrameAsImage">
<i class="las la-external-link"></i>
<span data-translate="copy-to-clipboard-frame">Snapshot to clipboard</span>
</a>
</li>
<li class="context-menu__item hidden">
<a href="#" class="context-menu__link" data-action="SaveFrameToDisk">
<i class="las la-external-link"></i>
<span data-translate="save-current-frame">Save frame to disk</span>
</a>
</li>
<li class="context-menu__item">
<a href="#" class="context-menu__link" data-action="ShowStats">
<i class="las la-external-link"></i>
@ -2480,11 +2493,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
</script>
<script type="text/javascript" crossorigin="anonymous" id="lib-js" src="./lib.js?ver=696"></script>
<script type="text/javascript" crossorigin="anonymous" id="lib-js" src="./lib.js?ver=701"></script>
<!--
// If you wish to change branding, blank offers a good clean start.
<script type="text/javascript" id="main-js" src="./main.js" data-translation="blank"></script>
-->
<script type="text/javascript" crossorigin="anonymous" id="main-js" src="./main.js?ver=569"></script>
<script type="text/javascript" crossorigin="anonymous" id="main-js" src="./main.js?ver=571"></script>
</body>
</html>

108
lib.js
View File

@ -13025,7 +13025,7 @@ function soloLinkGenerator(streamID, scene=true){
}
var wss = "";
if (session.customWSS || session.wssSetViaUrl){
if (session.wssSetViaUrl){
if (session.customWSS && (session.customWSS!==true)){
wss = "&pie="+session.customWSS;
} else {
@ -13384,7 +13384,7 @@ function updatePushId(){
updateURL("push="+session.streamID);
} else if (urlParams.has('id')){
updateURL("id="+session.streamID);
} else if (urlParams.has('permaid')){
} else if (urlParams.has('permaid')){
updateURL("permaid="+session.streamID);
} else {
updateURL("push="+session.streamID);
@ -14703,6 +14703,57 @@ async function createRoom(roomname = false) {
pokeIframeAPI("create-room", roomname);
}
function copyVideoFrameToClipboard(videoElement, e=false) {
try{
var canvas = document.createElement("canvas");
canvas.width = videoElement.videoWidth;
canvas.height = videoElement.videoHeight;
var ctx = canvas.getContext("2d");
ctx.drawImage(videoElement, 0, 0);
var img = new Image();
img.src = canvas.toDataURL();
canvas.toBlob(function(blob) {
navigator.clipboard.write([new ClipboardItem({'image/png': blob})]);
}, 'image/png');
popupMessage(e, "Frame copied to clipboard as as PNG Image");
} catch(e){
errorlog(e);
}
}
function saveVideoFrameToClipboard(videoElement, e=false) {
try{
var canvas = document.createElement("canvas");
canvas.width = videoElement.videoWidth;
canvas.height = videoElement.videoHeight;
var ctx = canvas.getContext("2d");
ctx.drawImage(videoElement, 0, 0);
var img = new Image();
img.src = canvas.toDataURL();
canvas.toBlob(function(blob) {
var link = document.createElement("a");
link.download = (videoElement.id||"video")+"_"+parseInt(performance.now())+".png";
link.href = URL.createObjectURL(blob);
link.click();
URL.revokeObjectURL(link.href);
}, 'image/png');
popupMessage(e, "Saving current frame to disk");
} catch(e){
errorlog(e);
}
}
async function checkDirectorStreamID(){
if (session.directorStreamID){
for (var UUID in session.rpcs){
@ -15026,7 +15077,7 @@ async function createRoomCallback(passAdd, passAdd2) {
}
var wss = "";
if (session.customWSS || session.wssSetViaUrl){
if (session.wssSetViaUrl){
if (session.customWSS && (session.customWSS!==true)){
wss = "&pie="+session.customWSS;
} else {
@ -16822,23 +16873,26 @@ function gotDevices(deviceInfos) {
deviceInfos = tmp;
if (typeof session.audioDevice == "object") { // this sorts according to users's manual selection
var tmp = [];
var matched = [];
var notmatched = [];
for (let i = 0; i !== deviceInfos.length; ++i) {
if (deviceInfos[i].kind === 'audioinput'){
if (session.audioDevice.includes(deviceInfos[i].deviceId)) {
tmp.push(deviceInfos[i]);
matched.push(deviceInfos[i]);
} else {
for (var j=0;j<session.audioDevice.length;j++){
if (deviceInfos[i].label.replace(/[\W]+/g, "_").toLowerCase().includes(session.audioDevice[j])) {
tmp.push(deviceInfos[i]);
matched.push(deviceInfos[i]);
log("A DEVICE FOUND = " + deviceInfos[i].label);
break;
}
}
}
} else {
notmatched.push(deviceInfos[i]);
}
}
deviceInfos = tmp;
deviceInfos = matched.concat(notmatched);
} else if (session.store && session.store.SelectedAudioInputDevices){
var matched = [];
var notmatch = [];
@ -16871,11 +16925,12 @@ function gotDevices(deviceInfos) {
deviceInfos = matched.concat(notmatch);
}
if ((session.videoDevice) && (session.videoDevice !== 1)){ // this sorts according to users's manual selection
if (session.videoDevice && (session.videoDevice !== 1)){ // this sorts according to users's manual selection
var tmp = [];
var tmp2 = [];
var tmp3 = [];
for (let i = 0; i !== deviceInfos.length; ++i) {
deviceInfo = deviceInfos[i];
if ((deviceInfo.kind === 'videoinput') && (deviceInfo.label.replace(/[\W]+/g, "_").toLowerCase().startsWith(session.videoDevice))) {
@ -16935,7 +16990,7 @@ function gotDevices(deviceInfos) {
deviceInfos = tmp;
log("VDECICE:" + session.videoDevice);
log(deviceInfos);
} else if (session.store && session.store.SelectedVideoInputDevices){
} else if (session.store && session.store.SelectedVideoInputDevices && (session.videoDevice===false)){
var matched = [];
var notmatch = [];
for (let i = 0; i !== deviceInfos.length; ++i) {
@ -18886,9 +18941,6 @@ function obfuscateURL(input) {
input = input.replace('&fps=', '&fr=');
input = input.replace('?fps=', '?fr=');
input = input.replace('&permaid=', '&push=');
input = input.replace('?permaid=', '?push=');
input = input.replace('&roomid=', '&r=');
input = input.replace('?roomid=', '?r=');
@ -22785,7 +22837,7 @@ function updateReshareLink(){
}
var wss = "";
if (session.customWSS || session.wssSetViaUrl){
if (session.wssSetViaUrl){
if (session.customWSS && (session.customWSS!==true)){
wss = "&pie="+session.customWSS;
} else {
@ -27979,7 +28031,7 @@ function generateQRPageCallback(hash) {
var wss = "";
if (session.customWSS || session.wssSetViaUrl){
if (session.wssSetViaUrl){
if (session.customWSS && (session.customWSS!==true)){
wss = "&pie="+session.customWSS;
} else {
@ -28259,7 +28311,7 @@ function pauseVideo(videoEle, update=true){
if (clickeElIsLink) {
e.preventDefault();
e.stopPropagation();
menuItemListener(clickeElIsLink);
menuItemListener(clickeElIsLink, false, e);
return false;
} else {
var button = e.which || e.button;
@ -28274,7 +28326,7 @@ function pauseVideo(videoEle, update=true){
if (clickeElIsLink) {
e.preventDefault();
e.stopPropagation();
menuItemListener(clickeElIsLink, e.srcElement);
menuItemListener(clickeElIsLink, e.srcElement, e);
return false;
} else {
var button = e.which || e.button;
@ -28351,7 +28403,7 @@ function pauseVideo(videoEle, update=true){
}
}
async function menuItemListener(link, inputElement=false) {
async function menuItemListener(link, inputElement=false, e=false) {
if (link.getAttribute("data-action") === "Open") {
window.open(taskItemInContext.href);
} else if (link.getAttribute("data-action") === "Copy") {
@ -28400,6 +28452,10 @@ function pauseVideo(videoEle, update=true){
} else if (taskItemInContext.recording){
recordLocalVideo("stop", null, taskItemInContext);
}
} else if (link.getAttribute("data-action") === "CopyFrameAsImage") {
copyVideoFrameToClipboard(taskItemInContext, e);
} else if (link.getAttribute("data-action") === "SaveFrameToDisk") {
saveVideoFrameToClipboard(taskItemInContext, e);
} else if (link.getAttribute("data-action") === "ChangeBuffer") {
toggleBufferSettings(taskItemInContext.dataset.UUID);
} else if (link.getAttribute("data-action") === "Cast") {
@ -28558,6 +28614,18 @@ function pauseVideo(videoEle, update=true){
} else {
items[i].parentNode.classList.add("hidden");
}
} else if (items[i].getAttribute("data-action") === "CopyFrameAsImage") {
if (taskItemInContext.srcObject && taskItemInContext.srcObject.getVideoTracks().length){
items[i].parentNode.classList.remove("hidden");
} else {
items[i].parentNode.classList.add("hidden");
}
} else if (items[i].getAttribute("data-action") === "SaveFrameToDisk") {
if (taskItemInContext.srcObject && taskItemInContext.srcObject.getVideoTracks().length){
items[i].parentNode.classList.remove("hidden");
} else {
items[i].parentNode.classList.add("hidden");
}
} else if (items[i].getAttribute("data-action") === "Controls") {
if (taskItemInContext.controls){
items[i].parentNode.classList.add("hidden");
@ -28709,13 +28777,15 @@ function popupMessage(e, message = "Copied to Clipboard") { // right click menu
}
menu.classList.remove("fadeout");
var showlength = message.length*50 || 500;
setTimeout(function() {
menu.classList.add("fadeout");
}, 500);
}, showlength);
setTimeout(function() {
toggleMenuOff();
}, 1500);
}, showlength+1000);
}
function timeSince(date) {

View File

@ -4258,6 +4258,8 @@ input:checked + .slider:before {
box-shadow: 0px 5px 10px -5px #a9a9a9;
text-align: left;
font-size: 97%;
white-space:normal;
min-height: 44px;
}
.cameraTip > p {
text-align: left;

33
main.js
View File

@ -2237,6 +2237,7 @@ async function main(){ // main asyncronous thread; mostly initializes the user s
} else if (session.videoDevice) {
session.videoDevice = session.videoDevice.toLowerCase().replace(/[\W]+/g, "_");
}
if (session.videoDevice == "false") {
session.videoDevice = 0;
} else if (session.videoDevice == "0") {
@ -2259,10 +2260,7 @@ async function main(){ // main asyncronous thread; mostly initializes the user s
session.videoDevice = 1;
} else if (session.videoDevice == "default") {
session.videoDevice = 1;
} else {
// whatever the user entered I guess, santitized.
session.videoDevice = session.videoDevice.replace(/[\W]+/g, "_").toLowerCase();
}
}
if (!urlParams.has('vdo')){
getById("videoMenu").style.display = "none";
@ -2278,9 +2276,9 @@ async function main(){ // main asyncronous thread; mostly initializes the user s
if (session.audioDevice === null) {
session.audioDevice = "1";
} //else if (session.audioDevice) {
// session.audioDevice = session.audioDevice.toLowerCase().replace(/[\W]+/g, "_");
//}
} else if (session.audioDevice) {
session.audioDevice = session.audioDevice.toLowerCase().replace(/[^-,'A-Za-z0-9]+/g,"_");
}
if (session.audioDevice == "false") {
session.audioDevice = 0;
@ -2299,15 +2297,11 @@ async function main(){ // main asyncronous thread; mostly initializes the user s
} else if (session.audioDevice == "ndi") {
session.audioDevice = ["line_newtek_ndi_audio"];
} else {
// whatever the user entered I guess
session.audioDevice = session.audioDevice.split(",");
for (var i =0;i<session.audioDevice.length;i++){
session.audioDevice[i] = session.audioDevice[i].replace(/[\W]+/g, "_").toLowerCase();
log("session.audioDevice:" + session.audioDevice[i]);
}
}
getById("headphonesDiv").style.display = "none";
getById("headphonesDiv2").style.display = "none";
if (typeof session.audioDevice !== "object"){
getById("audioMenu").style.display = "none";
getById("audioScreenShare1").style.display = "none";
@ -3676,21 +3670,30 @@ async function main(){ // main asyncronous thread; mostly initializes the user s
}
}
}
if (urlParams.has('queue')) {
session.queue = true;
}
if (urlParams.has('push') || urlParams.has('id') || urlParams.has('permaid') ) {
session.permaid = urlParams.get('push') || urlParams.get('id') || urlParams.get('permaid');
if (session.permaid) {
session.streamID = sanitizeStreamID(session.permaid);
session.permaid = sanitizeStreamID(session.permaid) || null;
session.streamID = session.permaid || session.streamID;
} else if (urlParams.has('permaid') && getStorage("permaid")){
session.streamID = sanitizeStreamID(getStorage("permaid")) || session.streamID;
session.permaid = null;
} else {
session.permaid = null;
}
if (urlParams.has('permaid')){
setStorage("permaid", session.streamID, 99999)
}
if (urlParams.has('push')){
updateURL("push="+session.streamID, true, false);
} else if (urlParams.has('id')){

File diff suppressed because one or more lines are too long