Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- pics/Virtual_Background.jpg +3 -0
- pics/improved_vp.jpg +0 -0
- static/app.js +853 -57
- static/index.html +55 -0
- static/styles.css +177 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
pics/Virtual_Background.jpg filter=lfs diff=lfs merge=lfs -text
|
pics/Virtual_Background.jpg
ADDED
|
Git LFS Details
|
pics/improved_vp.jpg
ADDED
|
static/app.js
CHANGED
|
@@ -24,6 +24,24 @@ let bgBlurEnabled = false;
|
|
| 24 |
let bgBlurCanvas = null;
|
| 25 |
let bgBlurCtx = null;
|
| 26 |
let bgBlurStream = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
// Map of peer_id -> { pc: RTCPeerConnection, videoEl, tile, name }
|
| 29 |
const peerConnections = {};
|
|
@@ -393,6 +411,10 @@ function enterCallScreen() {
|
|
| 393 |
if (myRole === "host") {
|
| 394 |
showHostControls();
|
| 395 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 396 |
}
|
| 397 |
|
| 398 |
// ββ Call Control Listeners βββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -559,6 +581,53 @@ function setupCallControls() {
|
|
| 559 |
document.getElementById("notesPanel").classList.remove("open");
|
| 560 |
});
|
| 561 |
document.getElementById("saveNotesBtn").addEventListener("click", saveNotes);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 562 |
}
|
| 563 |
|
| 564 |
function toggleMic() {
|
|
@@ -664,12 +733,19 @@ function leaveCall() {
|
|
| 664 |
chatOpen = false;
|
| 665 |
handRaised = false;
|
| 666 |
myRole = "participant";
|
|
|
|
|
|
|
|
|
|
| 667 |
chatPanel.classList.remove("open");
|
| 668 |
document.querySelectorAll(".side-panel").forEach(p => p.classList.remove("open"));
|
|
|
|
| 669 |
|
| 670 |
clearInterval(meetingTimerInterval);
|
| 671 |
meetingTimerInterval = null;
|
| 672 |
|
|
|
|
|
|
|
|
|
|
| 673 |
// Hide waiting room overlay
|
| 674 |
document.getElementById("waitingRoomOverlay").style.display = "none";
|
| 675 |
|
|
@@ -871,6 +947,7 @@ function getOrCreatePeer(peerId, peerName) {
|
|
| 871 |
tile.innerHTML = `
|
| 872 |
<video autoplay playsinline></video>
|
| 873 |
<div class="video-off-overlay" style="display:flex"><div class="avatar">π€</div></div>
|
|
|
|
| 874 |
<div class="tile-label">
|
| 875 |
<span class="tile-name">${escapeHtml(peerName || "Peer")}</span>
|
| 876 |
<span class="mic-indicator">π€</span>
|
|
@@ -883,6 +960,9 @@ function getOrCreatePeer(peerId, peerName) {
|
|
| 883 |
videoEl.volume = 1.0;
|
| 884 |
const offOverlay = tile.querySelector(".video-off-overlay");
|
| 885 |
|
|
|
|
|
|
|
|
|
|
| 886 |
const conn = { pc, videoEl, tile, name: peerName, offOverlay };
|
| 887 |
peerConnections[peerId] = conn;
|
| 888 |
|
|
@@ -914,6 +994,11 @@ function getOrCreatePeer(peerId, peerName) {
|
|
| 914 |
|
| 915 |
offOverlay.style.display = "none";
|
| 916 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 917 |
// Force play to handle autoplay policy
|
| 918 |
videoEl.play().catch(err => {
|
| 919 |
console.warn("[track] Autoplay blocked for", peerId, err);
|
|
@@ -1031,6 +1116,8 @@ function removePeer(peerId) {
|
|
| 1031 |
conn.pc.close();
|
| 1032 |
conn.tile.remove();
|
| 1033 |
delete peerConnections[peerId];
|
|
|
|
|
|
|
| 1034 |
|
| 1035 |
const name = conn.name || "Someone";
|
| 1036 |
showToast(`${name} left`);
|
|
@@ -1455,64 +1542,13 @@ function hideBreakoutActive() {
|
|
| 1455 |
}
|
| 1456 |
|
| 1457 |
// ββ Background Blur βββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1458 |
-
function toggleBgBlur() {
|
| 1459 |
-
bgBlurEnabled =
|
| 1460 |
-
|
| 1461 |
-
|
| 1462 |
-
|
| 1463 |
-
if (bgBlurEnabled) {
|
| 1464 |
-
if (!localStream) return;
|
| 1465 |
-
const videoTrack = localStream.getVideoTracks()[0];
|
| 1466 |
-
if (!videoTrack) return;
|
| 1467 |
-
|
| 1468 |
-
bgBlurCanvas = document.createElement("canvas");
|
| 1469 |
-
bgBlurCanvas.width = 640;
|
| 1470 |
-
bgBlurCanvas.height = 480;
|
| 1471 |
-
bgBlurCtx = bgBlurCanvas.getContext("2d");
|
| 1472 |
-
|
| 1473 |
-
const tempVideo = document.createElement("video");
|
| 1474 |
-
tempVideo.srcObject = new MediaStream([videoTrack]);
|
| 1475 |
-
tempVideo.muted = true;
|
| 1476 |
-
tempVideo.play();
|
| 1477 |
-
|
| 1478 |
-
const draw = () => {
|
| 1479 |
-
if (!bgBlurEnabled) return;
|
| 1480 |
-
bgBlurCtx.filter = "blur(10px)";
|
| 1481 |
-
bgBlurCtx.drawImage(tempVideo, 0, 0, bgBlurCanvas.width, bgBlurCanvas.height);
|
| 1482 |
-
bgBlurCtx.filter = "none";
|
| 1483 |
-
|
| 1484 |
-
// Draw center region sharp (person approximation)
|
| 1485 |
-
const cx = bgBlurCanvas.width * 0.15;
|
| 1486 |
-
const cy = bgBlurCanvas.height * 0.05;
|
| 1487 |
-
const cw = bgBlurCanvas.width * 0.7;
|
| 1488 |
-
const ch = bgBlurCanvas.height * 0.9;
|
| 1489 |
-
bgBlurCtx.drawImage(tempVideo, cx, cy, cw, ch, cx, cy, cw, ch);
|
| 1490 |
-
|
| 1491 |
-
requestAnimationFrame(draw);
|
| 1492 |
-
};
|
| 1493 |
-
draw();
|
| 1494 |
-
|
| 1495 |
-
bgBlurStream = bgBlurCanvas.captureStream(30);
|
| 1496 |
-
const blurTrack = bgBlurStream.getVideoTracks()[0];
|
| 1497 |
-
|
| 1498 |
-
// Replace in all peer connections
|
| 1499 |
-
for (const pid in peerConnections) {
|
| 1500 |
-
const sender = peerConnections[pid].pc.getSenders().find(s => s.track?.kind === "video");
|
| 1501 |
-
if (sender) sender.replaceTrack(blurTrack);
|
| 1502 |
-
}
|
| 1503 |
-
localVideo.srcObject = bgBlurStream;
|
| 1504 |
} else {
|
| 1505 |
-
//
|
| 1506 |
-
|
| 1507 |
-
for (const pid in peerConnections) {
|
| 1508 |
-
const sender = peerConnections[pid].pc.getSenders().find(s => s.track?.kind === "video");
|
| 1509 |
-
if (sender && camTrack) sender.replaceTrack(camTrack);
|
| 1510 |
-
}
|
| 1511 |
-
localVideo.srcObject = localStream;
|
| 1512 |
-
if (bgBlurStream) {
|
| 1513 |
-
bgBlurStream.getTracks().forEach(t => t.stop());
|
| 1514 |
-
bgBlurStream = null;
|
| 1515 |
-
}
|
| 1516 |
}
|
| 1517 |
}
|
| 1518 |
|
|
@@ -1668,3 +1704,763 @@ function saveNotes() {
|
|
| 1668 |
|
| 1669 |
showToast("Meeting notes saved!");
|
| 1670 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
let bgBlurCanvas = null;
|
| 25 |
let bgBlurCtx = null;
|
| 26 |
let bgBlurStream = null;
|
| 27 |
+
let selfieSegmenter = null;
|
| 28 |
+
let segMask = null;
|
| 29 |
+
let vbgTempVideo = null;
|
| 30 |
+
let vbgSceneBg = null;
|
| 31 |
+
let vbgMode = null; // 'blur' | 'scene'
|
| 32 |
+
let vbgPersonCanvas = null;
|
| 33 |
+
let vbgPersonCtx = null;
|
| 34 |
+
let vbgMaskCanvas = null;
|
| 35 |
+
let vbgMaskCtx = null;
|
| 36 |
+
let vbgTempMaskCanvas = null;
|
| 37 |
+
let vbgTempMaskCtx = null;
|
| 38 |
+
let vbgPrevMask = null; // Uint8Array for temporal smoothing
|
| 39 |
+
let vbgUseFallback = false;
|
| 40 |
+
let vbgFallbackMask = null;
|
| 41 |
+
let viewMode = "gallery"; // "gallery" | "speaker"
|
| 42 |
+
let pinnedPeerId = null;
|
| 43 |
+
let currentVbg = "none";
|
| 44 |
+
let audioAnalysers = {}; // peer_id -> { analyser, dataArray }
|
| 45 |
|
| 46 |
// Map of peer_id -> { pc: RTCPeerConnection, videoEl, tile, name }
|
| 47 |
const peerConnections = {};
|
|
|
|
| 411 |
if (myRole === "host") {
|
| 412 |
showHostControls();
|
| 413 |
}
|
| 414 |
+
|
| 415 |
+
// Start speaker detection
|
| 416 |
+
startSpeakerDetectionLoop();
|
| 417 |
+
applyViewMode();
|
| 418 |
}
|
| 419 |
|
| 420 |
// ββ Call Control Listeners βββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 581 |
document.getElementById("notesPanel").classList.remove("open");
|
| 582 |
});
|
| 583 |
document.getElementById("saveNotesBtn").addEventListener("click", saveNotes);
|
| 584 |
+
|
| 585 |
+
// View toggle
|
| 586 |
+
document.getElementById("viewToggleBtn").addEventListener("click", toggleViewMode);
|
| 587 |
+
|
| 588 |
+
// Device selector
|
| 589 |
+
document.getElementById("deviceSelectBtn").addEventListener("click", openDeviceSelector);
|
| 590 |
+
document.getElementById("closeDeviceModal").addEventListener("click", () => {
|
| 591 |
+
document.getElementById("deviceModal").style.display = "none";
|
| 592 |
+
});
|
| 593 |
+
document.getElementById("camSelect").addEventListener("change", (e) => switchCamera(e.target.value));
|
| 594 |
+
document.getElementById("micSelect").addEventListener("change", (e) => switchMicrophone(e.target.value));
|
| 595 |
+
document.getElementById("speakerSelect").addEventListener("change", (e) => switchSpeaker(e.target.value));
|
| 596 |
+
|
| 597 |
+
// Virtual background
|
| 598 |
+
document.getElementById("virtualBgBtn").addEventListener("click", openVirtualBgModal);
|
| 599 |
+
document.getElementById("closeVbgModal").addEventListener("click", () => {
|
| 600 |
+
document.getElementById("vbgModal").style.display = "none";
|
| 601 |
+
});
|
| 602 |
+
document.querySelectorAll(".vbg-option").forEach(opt => {
|
| 603 |
+
opt.addEventListener("click", () => {
|
| 604 |
+
document.querySelectorAll(".vbg-option").forEach(o => o.classList.remove("active"));
|
| 605 |
+
opt.classList.add("active");
|
| 606 |
+
applyVirtualBg(opt.dataset.bg);
|
| 607 |
+
document.getElementById("vbgModal").style.display = "none";
|
| 608 |
+
});
|
| 609 |
+
});
|
| 610 |
+
|
| 611 |
+
// Keyboard shortcuts modal
|
| 612 |
+
document.getElementById("shortcutsBtn").addEventListener("click", () => {
|
| 613 |
+
document.getElementById("shortcutsModal").style.display = "flex";
|
| 614 |
+
});
|
| 615 |
+
document.getElementById("closeShortcutsModal").addEventListener("click", () => {
|
| 616 |
+
document.getElementById("shortcutsModal").style.display = "none";
|
| 617 |
+
});
|
| 618 |
+
|
| 619 |
+
// Close modals on overlay click
|
| 620 |
+
document.querySelectorAll(".modal-overlay").forEach(overlay => {
|
| 621 |
+
overlay.addEventListener("click", (e) => {
|
| 622 |
+
if (e.target === overlay) overlay.style.display = "none";
|
| 623 |
+
});
|
| 624 |
+
});
|
| 625 |
+
|
| 626 |
+
// Pin local video
|
| 627 |
+
document.getElementById("localTile")?.addEventListener("dblclick", () => togglePin("local"));
|
| 628 |
+
|
| 629 |
+
// Keyboard shortcuts
|
| 630 |
+
setupKeyboardShortcuts();
|
| 631 |
}
|
| 632 |
|
| 633 |
function toggleMic() {
|
|
|
|
| 733 |
chatOpen = false;
|
| 734 |
handRaised = false;
|
| 735 |
myRole = "participant";
|
| 736 |
+
pinnedPeerId = null;
|
| 737 |
+
viewMode = "gallery";
|
| 738 |
+
currentVbg = "none";
|
| 739 |
chatPanel.classList.remove("open");
|
| 740 |
document.querySelectorAll(".side-panel").forEach(p => p.classList.remove("open"));
|
| 741 |
+
document.querySelectorAll(".modal-overlay").forEach(m => m.style.display = "none");
|
| 742 |
|
| 743 |
clearInterval(meetingTimerInterval);
|
| 744 |
meetingTimerInterval = null;
|
| 745 |
|
| 746 |
+
stopSpeakerDetectionLoop();
|
| 747 |
+
for (const pid in audioAnalysers) cleanupSpeakerDetection(pid);
|
| 748 |
+
|
| 749 |
// Hide waiting room overlay
|
| 750 |
document.getElementById("waitingRoomOverlay").style.display = "none";
|
| 751 |
|
|
|
|
| 947 |
tile.innerHTML = `
|
| 948 |
<video autoplay playsinline></video>
|
| 949 |
<div class="video-off-overlay" style="display:flex"><div class="avatar">π€</div></div>
|
| 950 |
+
<button class="pin-btn" title="Pin video"><span class="material-icons-round">push_pin</span></button>
|
| 951 |
<div class="tile-label">
|
| 952 |
<span class="tile-name">${escapeHtml(peerName || "Peer")}</span>
|
| 953 |
<span class="mic-indicator">π€</span>
|
|
|
|
| 960 |
videoEl.volume = 1.0;
|
| 961 |
const offOverlay = tile.querySelector(".video-off-overlay");
|
| 962 |
|
| 963 |
+
// Pin button
|
| 964 |
+
tile.querySelector(".pin-btn").addEventListener("click", () => togglePin(peerId));
|
| 965 |
+
|
| 966 |
const conn = { pc, videoEl, tile, name: peerName, offOverlay };
|
| 967 |
peerConnections[peerId] = conn;
|
| 968 |
|
|
|
|
| 994 |
|
| 995 |
offOverlay.style.display = "none";
|
| 996 |
|
| 997 |
+
// Setup speaker detection for audio tracks
|
| 998 |
+
if (event.track.kind === "audio") {
|
| 999 |
+
setupSpeakerDetection(peerId, event.streams[0]);
|
| 1000 |
+
}
|
| 1001 |
+
|
| 1002 |
// Force play to handle autoplay policy
|
| 1003 |
videoEl.play().catch(err => {
|
| 1004 |
console.warn("[track] Autoplay blocked for", peerId, err);
|
|
|
|
| 1116 |
conn.pc.close();
|
| 1117 |
conn.tile.remove();
|
| 1118 |
delete peerConnections[peerId];
|
| 1119 |
+
cleanupSpeakerDetection(peerId);
|
| 1120 |
+
if (pinnedPeerId === peerId) pinnedPeerId = null;
|
| 1121 |
|
| 1122 |
const name = conn.name || "Someone";
|
| 1123 |
showToast(`${name} left`);
|
|
|
|
| 1542 |
}
|
| 1543 |
|
| 1544 |
// ββ Background Blur βββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1545 |
+
async function toggleBgBlur() {
|
| 1546 |
+
if (bgBlurEnabled && vbgMode === 'blur') {
|
| 1547 |
+
// Turn off blur
|
| 1548 |
+
applyVirtualBg('none');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1549 |
} else {
|
| 1550 |
+
// Turn on blur
|
| 1551 |
+
await applyVirtualBg('blur');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1552 |
}
|
| 1553 |
}
|
| 1554 |
|
|
|
|
| 1704 |
|
| 1705 |
showToast("Meeting notes saved!");
|
| 1706 |
}
|
| 1707 |
+
|
| 1708 |
+
// ββ View Toggle (Gallery / Speaker) βββββββββββββββββββββββββββββββββββββ
|
| 1709 |
+
function toggleViewMode() {
|
| 1710 |
+
viewMode = viewMode === "gallery" ? "speaker" : "gallery";
|
| 1711 |
+
const label = document.getElementById("viewToggleLabel");
|
| 1712 |
+
const icon = document.getElementById("viewToggleBtn").querySelector(".material-icons-round");
|
| 1713 |
+
if (viewMode === "speaker") {
|
| 1714 |
+
label.textContent = "Speaker";
|
| 1715 |
+
icon.textContent = "view_sidebar";
|
| 1716 |
+
} else {
|
| 1717 |
+
label.textContent = "Gallery";
|
| 1718 |
+
icon.textContent = "grid_view";
|
| 1719 |
+
}
|
| 1720 |
+
applyViewMode();
|
| 1721 |
+
}
|
| 1722 |
+
|
| 1723 |
+
function applyViewMode() {
|
| 1724 |
+
const grid = document.getElementById("videoGrid");
|
| 1725 |
+
grid.classList.remove("view-gallery", "view-speaker");
|
| 1726 |
+
grid.classList.add(viewMode === "speaker" ? "view-speaker" : "view-gallery");
|
| 1727 |
+
|
| 1728 |
+
// In speaker mode, spotlight the pinned peer or the active speaker
|
| 1729 |
+
if (viewMode === "speaker") {
|
| 1730 |
+
const spotlightId = pinnedPeerId || findActiveSpeaker() || "local";
|
| 1731 |
+
grid.querySelectorAll(".video-tile").forEach(tile => {
|
| 1732 |
+
tile.classList.toggle("spotlight", tile.dataset.peer === spotlightId);
|
| 1733 |
+
});
|
| 1734 |
+
} else {
|
| 1735 |
+
grid.querySelectorAll(".video-tile").forEach(tile => {
|
| 1736 |
+
tile.classList.remove("spotlight");
|
| 1737 |
+
});
|
| 1738 |
+
}
|
| 1739 |
+
}
|
| 1740 |
+
|
| 1741 |
+
function findActiveSpeaker() {
|
| 1742 |
+
let loudest = null;
|
| 1743 |
+
let loudestLevel = 0;
|
| 1744 |
+
for (const pid in audioAnalysers) {
|
| 1745 |
+
const { analyser, dataArray } = audioAnalysers[pid];
|
| 1746 |
+
analyser.getByteFrequencyData(dataArray);
|
| 1747 |
+
const avg = dataArray.reduce((a, b) => a + b, 0) / dataArray.length;
|
| 1748 |
+
if (avg > loudestLevel && avg > 15) {
|
| 1749 |
+
loudestLevel = avg;
|
| 1750 |
+
loudest = pid;
|
| 1751 |
+
}
|
| 1752 |
+
}
|
| 1753 |
+
return loudest;
|
| 1754 |
+
}
|
| 1755 |
+
|
| 1756 |
+
// ββ Pin / Spotlight Video βββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1757 |
+
function togglePin(peerId) {
|
| 1758 |
+
if (pinnedPeerId === peerId) {
|
| 1759 |
+
pinnedPeerId = null;
|
| 1760 |
+
showToast("Unpinned video");
|
| 1761 |
+
} else {
|
| 1762 |
+
pinnedPeerId = peerId;
|
| 1763 |
+
const name = peerConnections[peerId]?.name || "Peer";
|
| 1764 |
+
showToast(`Pinned ${name}`);
|
| 1765 |
+
}
|
| 1766 |
+
// Update pin button styling
|
| 1767 |
+
videoGrid.querySelectorAll(".pin-btn").forEach(btn => {
|
| 1768 |
+
const tile = btn.closest(".video-tile");
|
| 1769 |
+
btn.classList.toggle("active", tile.dataset.peer === pinnedPeerId);
|
| 1770 |
+
});
|
| 1771 |
+
applyViewMode();
|
| 1772 |
+
}
|
| 1773 |
+
|
| 1774 |
+
// ββ Speaker Active Indicator ββββββββββββββββββββββββββββββββββββββββββββ
|
| 1775 |
+
function setupSpeakerDetection(peerId, stream) {
|
| 1776 |
+
try {
|
| 1777 |
+
const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
| 1778 |
+
const source = audioCtx.createMediaStreamSource(stream);
|
| 1779 |
+
const analyser = audioCtx.createAnalyser();
|
| 1780 |
+
analyser.fftSize = 256;
|
| 1781 |
+
analyser.smoothingTimeConstant = 0.5;
|
| 1782 |
+
source.connect(analyser);
|
| 1783 |
+
const dataArray = new Uint8Array(analyser.frequencyBinCount);
|
| 1784 |
+
audioAnalysers[peerId] = { analyser, dataArray, audioCtx };
|
| 1785 |
+
} catch (e) {
|
| 1786 |
+
console.warn("[speaker] Failed to setup detection for", peerId, e);
|
| 1787 |
+
}
|
| 1788 |
+
}
|
| 1789 |
+
|
| 1790 |
+
function cleanupSpeakerDetection(peerId) {
|
| 1791 |
+
if (audioAnalysers[peerId]) {
|
| 1792 |
+
audioAnalysers[peerId].audioCtx.close().catch(() => {});
|
| 1793 |
+
delete audioAnalysers[peerId];
|
| 1794 |
+
}
|
| 1795 |
+
}
|
| 1796 |
+
|
| 1797 |
+
let speakerDetectionInterval = null;
|
| 1798 |
+
function startSpeakerDetectionLoop() {
|
| 1799 |
+
if (speakerDetectionInterval) return;
|
| 1800 |
+
speakerDetectionInterval = setInterval(() => {
|
| 1801 |
+
for (const pid in audioAnalysers) {
|
| 1802 |
+
const { analyser, dataArray } = audioAnalysers[pid];
|
| 1803 |
+
analyser.getByteFrequencyData(dataArray);
|
| 1804 |
+
const avg = dataArray.reduce((a, b) => a + b, 0) / dataArray.length;
|
| 1805 |
+
const tile = peerConnections[pid]?.tile;
|
| 1806 |
+
if (tile) {
|
| 1807 |
+
tile.classList.toggle("speaking", avg > 15);
|
| 1808 |
+
}
|
| 1809 |
+
}
|
| 1810 |
+
// Auto-switch speaker view spotlight
|
| 1811 |
+
if (viewMode === "speaker" && !pinnedPeerId) {
|
| 1812 |
+
applyViewMode();
|
| 1813 |
+
}
|
| 1814 |
+
}, 300);
|
| 1815 |
+
}
|
| 1816 |
+
|
| 1817 |
+
function stopSpeakerDetectionLoop() {
|
| 1818 |
+
clearInterval(speakerDetectionInterval);
|
| 1819 |
+
speakerDetectionInterval = null;
|
| 1820 |
+
}
|
| 1821 |
+
|
| 1822 |
+
// ββ Device Selector βββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1823 |
+
async function openDeviceSelector() {
|
| 1824 |
+
const modal = document.getElementById("deviceModal");
|
| 1825 |
+
modal.style.display = "flex";
|
| 1826 |
+
|
| 1827 |
+
const devices = await navigator.mediaDevices.enumerateDevices();
|
| 1828 |
+
const camSelect = document.getElementById("camSelect");
|
| 1829 |
+
const micSelect = document.getElementById("micSelect");
|
| 1830 |
+
const speakerSelect = document.getElementById("speakerSelect");
|
| 1831 |
+
|
| 1832 |
+
const currentVideoId = localStream?.getVideoTracks()[0]?.getSettings()?.deviceId;
|
| 1833 |
+
const currentAudioId = localStream?.getAudioTracks()[0]?.getSettings()?.deviceId;
|
| 1834 |
+
|
| 1835 |
+
camSelect.innerHTML = devices.filter(d => d.kind === "videoinput").map(d =>
|
| 1836 |
+
`<option value="${d.deviceId}" ${d.deviceId === currentVideoId ? 'selected' : ''}>${d.label || 'Camera ' + d.deviceId.slice(0,4)}</option>`
|
| 1837 |
+
).join('');
|
| 1838 |
+
|
| 1839 |
+
micSelect.innerHTML = devices.filter(d => d.kind === "audioinput").map(d =>
|
| 1840 |
+
`<option value="${d.deviceId}" ${d.deviceId === currentAudioId ? 'selected' : ''}>${d.label || 'Mic ' + d.deviceId.slice(0,4)}</option>`
|
| 1841 |
+
).join('');
|
| 1842 |
+
|
| 1843 |
+
speakerSelect.innerHTML = devices.filter(d => d.kind === "audiooutput").map(d =>
|
| 1844 |
+
`<option value="${d.deviceId}">${d.label || 'Speaker ' + d.deviceId.slice(0,4)}</option>`
|
| 1845 |
+
).join('');
|
| 1846 |
+
}
|
| 1847 |
+
|
| 1848 |
+
async function switchCamera(deviceId) {
|
| 1849 |
+
try {
|
| 1850 |
+
const newStream = await navigator.mediaDevices.getUserMedia({
|
| 1851 |
+
video: { deviceId: { exact: deviceId } },
|
| 1852 |
+
audio: false,
|
| 1853 |
+
});
|
| 1854 |
+
const newTrack = newStream.getVideoTracks()[0];
|
| 1855 |
+
const oldTrack = localStream.getVideoTracks()[0];
|
| 1856 |
+
if (oldTrack) {
|
| 1857 |
+
localStream.removeTrack(oldTrack);
|
| 1858 |
+
oldTrack.stop();
|
| 1859 |
+
}
|
| 1860 |
+
localStream.addTrack(newTrack);
|
| 1861 |
+
for (const pid in peerConnections) {
|
| 1862 |
+
const sender = peerConnections[pid].pc.getSenders().find(s => s.track?.kind === "video");
|
| 1863 |
+
if (sender) sender.replaceTrack(newTrack);
|
| 1864 |
+
}
|
| 1865 |
+
localVideo.srcObject = localStream;
|
| 1866 |
+
showToast("Camera switched");
|
| 1867 |
+
} catch (e) {
|
| 1868 |
+
showToast("Failed to switch camera");
|
| 1869 |
+
}
|
| 1870 |
+
}
|
| 1871 |
+
|
| 1872 |
+
async function switchMicrophone(deviceId) {
|
| 1873 |
+
try {
|
| 1874 |
+
const newStream = await navigator.mediaDevices.getUserMedia({
|
| 1875 |
+
audio: { deviceId: { exact: deviceId }, echoCancellation: true, noiseSuppression: true, autoGainControl: true },
|
| 1876 |
+
video: false,
|
| 1877 |
+
});
|
| 1878 |
+
const newTrack = newStream.getAudioTracks()[0];
|
| 1879 |
+
const oldTrack = localStream.getAudioTracks()[0];
|
| 1880 |
+
if (oldTrack) {
|
| 1881 |
+
localStream.removeTrack(oldTrack);
|
| 1882 |
+
oldTrack.stop();
|
| 1883 |
+
}
|
| 1884 |
+
localStream.addTrack(newTrack);
|
| 1885 |
+
newTrack.enabled = micEnabled;
|
| 1886 |
+
for (const pid in peerConnections) {
|
| 1887 |
+
const sender = peerConnections[pid].pc.getSenders().find(s => s.track?.kind === "audio");
|
| 1888 |
+
if (sender) sender.replaceTrack(newTrack);
|
| 1889 |
+
}
|
| 1890 |
+
showToast("Microphone switched");
|
| 1891 |
+
} catch (e) {
|
| 1892 |
+
showToast("Failed to switch microphone");
|
| 1893 |
+
}
|
| 1894 |
+
}
|
| 1895 |
+
|
| 1896 |
+
async function switchSpeaker(deviceId) {
|
| 1897 |
+
try {
|
| 1898 |
+
for (const pid in peerConnections) {
|
| 1899 |
+
const el = peerConnections[pid].videoEl;
|
| 1900 |
+
if (el.setSinkId) await el.setSinkId(deviceId);
|
| 1901 |
+
}
|
| 1902 |
+
showToast("Speaker switched");
|
| 1903 |
+
} catch (e) {
|
| 1904 |
+
showToast("Failed to switch speaker");
|
| 1905 |
+
}
|
| 1906 |
+
}
|
| 1907 |
+
|
| 1908 |
+
// ββ Virtual Background ββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1909 |
+
const VBG_SCENES = {
|
| 1910 |
+
office: (ctx, w, h) => {
|
| 1911 |
+
// Warm beige office with bookshelf and window
|
| 1912 |
+
ctx.fillStyle = '#f5ebe0'; ctx.fillRect(0, 0, w, h);
|
| 1913 |
+
// Floor
|
| 1914 |
+
ctx.fillStyle = '#c8a882'; ctx.fillRect(0, h*0.65, w, h*0.35);
|
| 1915 |
+
ctx.fillStyle = '#b89b78'; ctx.fillRect(0, h*0.65, w, 3);
|
| 1916 |
+
// Wall molding
|
| 1917 |
+
ctx.fillStyle = '#e8d5c0'; ctx.fillRect(0, h*0.6, w, h*0.05);
|
| 1918 |
+
// Window with light
|
| 1919 |
+
const grad = ctx.createLinearGradient(w*0.55, h*0.08, w*0.55, h*0.5);
|
| 1920 |
+
grad.addColorStop(0, '#b8d4e8'); grad.addColorStop(1, '#dceaf5');
|
| 1921 |
+
ctx.fillStyle = '#8b7355'; ctx.fillRect(w*0.5, h*0.08, w*0.3, h*0.48);
|
| 1922 |
+
ctx.fillStyle = grad; ctx.fillRect(w*0.52, h*0.1, w*0.26, h*0.44);
|
| 1923 |
+
ctx.fillStyle = '#8b7355'; ctx.fillRect(w*0.64, h*0.08, w*0.02, h*0.48);
|
| 1924 |
+
ctx.fillStyle = '#8b7355'; ctx.fillRect(w*0.5, h*0.3, w*0.3, h*0.02);
|
| 1925 |
+
// Bookshelf
|
| 1926 |
+
ctx.fillStyle = '#6b4e37'; ctx.fillRect(w*0.05, h*0.1, w*0.25, h*0.5);
|
| 1927 |
+
for (let i = 0; i < 4; i++) {
|
| 1928 |
+
ctx.fillStyle = '#8b6b4a'; ctx.fillRect(w*0.05, h*(0.1+i*0.125), w*0.25, h*0.02);
|
| 1929 |
+
for (let j = 0; j < 5; j++) {
|
| 1930 |
+
const colors = ['#c0392b','#2980b9','#27ae60','#8e44ad','#e67e22'];
|
| 1931 |
+
ctx.fillStyle = colors[(i*5+j)%5];
|
| 1932 |
+
ctx.fillRect(w*(0.07+j*0.045), h*(0.13+i*0.125), w*0.035, h*0.09);
|
| 1933 |
+
}
|
| 1934 |
+
}
|
| 1935 |
+
// Plant
|
| 1936 |
+
ctx.fillStyle = '#654321'; ctx.fillRect(w*0.86, h*0.45, w*0.06, h*0.2);
|
| 1937 |
+
ctx.fillStyle = '#2d7a3a';
|
| 1938 |
+
ctx.beginPath(); ctx.arc(w*0.89, h*0.38, w*0.07, 0, Math.PI*2); ctx.fill();
|
| 1939 |
+
ctx.fillStyle = '#35914a';
|
| 1940 |
+
ctx.beginPath(); ctx.arc(w*0.87, h*0.34, w*0.05, 0, Math.PI*2); ctx.fill();
|
| 1941 |
+
},
|
| 1942 |
+
livingroom: (ctx, w, h) => {
|
| 1943 |
+
// Cozy living room with couch and lamp
|
| 1944 |
+
ctx.fillStyle = '#e8ddd0'; ctx.fillRect(0, 0, w, h);
|
| 1945 |
+
ctx.fillStyle = '#b8a089'; ctx.fillRect(0, h*0.7, w, h*0.3);
|
| 1946 |
+
// Rug
|
| 1947 |
+
ctx.fillStyle = '#8b5e3c'; ctx.fillRect(w*0.15, h*0.75, w*0.7, h*0.2);
|
| 1948 |
+
ctx.fillStyle = '#a0714f'; ctx.fillRect(w*0.18, h*0.78, w*0.64, h*0.14);
|
| 1949 |
+
// Couch
|
| 1950 |
+
ctx.fillStyle = '#4a6741';
|
| 1951 |
+
ctx.beginPath(); ctx.roundRect(w*0.1, h*0.4, w*0.6, h*0.25, 12); ctx.fill();
|
| 1952 |
+
ctx.fillStyle = '#3d5636';
|
| 1953 |
+
ctx.beginPath(); ctx.roundRect(w*0.08, h*0.35, w*0.07, h*0.3, 8); ctx.fill();
|
| 1954 |
+
ctx.beginPath(); ctx.roundRect(w*0.65, h*0.35, w*0.07, h*0.3, 8); ctx.fill();
|
| 1955 |
+
// Cushions
|
| 1956 |
+
ctx.fillStyle = '#5a7d50';
|
| 1957 |
+
ctx.beginPath(); ctx.roundRect(w*0.15, h*0.42, w*0.18, h*0.15, 8); ctx.fill();
|
| 1958 |
+
ctx.beginPath(); ctx.roundRect(w*0.38, h*0.42, w*0.18, h*0.15, 8); ctx.fill();
|
| 1959 |
+
// Lamp
|
| 1960 |
+
ctx.fillStyle = '#333'; ctx.fillRect(w*0.82, h*0.45, w*0.015, h*0.25);
|
| 1961 |
+
ctx.fillStyle = '#f0d58c';
|
| 1962 |
+
ctx.beginPath(); ctx.moveTo(w*0.78, h*0.45); ctx.lineTo(w*0.87, h*0.45); ctx.lineTo(w*0.85, h*0.32); ctx.lineTo(w*0.80, h*0.32); ctx.closePath(); ctx.fill();
|
| 1963 |
+
// Picture frame
|
| 1964 |
+
ctx.fillStyle = '#654321'; ctx.fillRect(w*0.3, h*0.08, w*0.2, h*0.2);
|
| 1965 |
+
ctx.fillStyle = '#87ceeb'; ctx.fillRect(w*0.32, h*0.1, w*0.16, h*0.16);
|
| 1966 |
+
ctx.fillStyle = '#2d8a4e'; ctx.fillRect(w*0.32, h*0.2, w*0.16, h*0.06);
|
| 1967 |
+
},
|
| 1968 |
+
nature: (ctx, w, h) => {
|
| 1969 |
+
// Forest/park scene
|
| 1970 |
+
const sky = ctx.createLinearGradient(0, 0, 0, h*0.5);
|
| 1971 |
+
sky.addColorStop(0, '#87ceeb'); sky.addColorStop(1, '#b5e6f5');
|
| 1972 |
+
ctx.fillStyle = sky; ctx.fillRect(0, 0, w, h*0.55);
|
| 1973 |
+
// Mountains
|
| 1974 |
+
ctx.fillStyle = '#6b8e7b';
|
| 1975 |
+
ctx.beginPath(); ctx.moveTo(0,h*0.5); ctx.lineTo(w*0.2,h*0.2); ctx.lineTo(w*0.4,h*0.45); ctx.lineTo(w*0.6,h*0.15); ctx.lineTo(w*0.8,h*0.4); ctx.lineTo(w,h*0.3); ctx.lineTo(w,h*0.55); ctx.closePath(); ctx.fill();
|
| 1976 |
+
// Ground
|
| 1977 |
+
const grass = ctx.createLinearGradient(0, h*0.5, 0, h);
|
| 1978 |
+
grass.addColorStop(0, '#4a8c5c'); grass.addColorStop(1, '#3a7048');
|
| 1979 |
+
ctx.fillStyle = grass; ctx.fillRect(0, h*0.5, w, h*0.5);
|
| 1980 |
+
// Trees
|
| 1981 |
+
for (let i = 0; i < 6; i++) {
|
| 1982 |
+
const x = w*(0.08 + i*0.16), ty = h*0.25 + Math.sin(i*2)*h*0.1;
|
| 1983 |
+
ctx.fillStyle = '#5c3a1e'; ctx.fillRect(x-w*0.01, ty+h*0.1, w*0.02, h*0.3);
|
| 1984 |
+
ctx.fillStyle = '#2d6b3f';
|
| 1985 |
+
ctx.beginPath(); ctx.arc(x, ty, w*0.06, 0, Math.PI*2); ctx.fill();
|
| 1986 |
+
ctx.fillStyle = '#38854d';
|
| 1987 |
+
ctx.beginPath(); ctx.arc(x+w*0.02, ty-h*0.02, w*0.04, 0, Math.PI*2); ctx.fill();
|
| 1988 |
+
}
|
| 1989 |
+
// Path
|
| 1990 |
+
ctx.fillStyle = '#c4a56e';
|
| 1991 |
+
ctx.beginPath(); ctx.moveTo(w*0.4, h); ctx.quadraticCurveTo(w*0.45, h*0.7, w*0.5, h*0.55); ctx.lineTo(w*0.53, h*0.55); ctx.quadraticCurveTo(w*0.55, h*0.7, w*0.6, h); ctx.closePath(); ctx.fill();
|
| 1992 |
+
},
|
| 1993 |
+
beach: (ctx, w, h) => {
|
| 1994 |
+
// Tropical beach
|
| 1995 |
+
const sky = ctx.createLinearGradient(0, 0, 0, h*0.45);
|
| 1996 |
+
sky.addColorStop(0, '#4db8e8'); sky.addColorStop(1, '#87d4f0');
|
| 1997 |
+
ctx.fillStyle = sky; ctx.fillRect(0, 0, w, h*0.45);
|
| 1998 |
+
// Sun
|
| 1999 |
+
ctx.fillStyle = '#ffe066';
|
| 2000 |
+
ctx.beginPath(); ctx.arc(w*0.8, h*0.12, w*0.06, 0, Math.PI*2); ctx.fill();
|
| 2001 |
+
// Clouds
|
| 2002 |
+
ctx.fillStyle = 'rgba(255,255,255,0.7)';
|
| 2003 |
+
ctx.beginPath(); ctx.arc(w*0.2, h*0.1, w*0.05, 0, Math.PI*2); ctx.fill();
|
| 2004 |
+
ctx.beginPath(); ctx.arc(w*0.25, h*0.08, w*0.04, 0, Math.PI*2); ctx.fill();
|
| 2005 |
+
// Ocean
|
| 2006 |
+
const ocean = ctx.createLinearGradient(0, h*0.4, 0, h*0.6);
|
| 2007 |
+
ocean.addColorStop(0, '#1a8fba'); ocean.addColorStop(1, '#2ba5d0');
|
| 2008 |
+
ctx.fillStyle = ocean; ctx.fillRect(0, h*0.4, w, h*0.2);
|
| 2009 |
+
// Sand
|
| 2010 |
+
const sand = ctx.createLinearGradient(0, h*0.55, 0, h);
|
| 2011 |
+
sand.addColorStop(0, '#f0d68c'); sand.addColorStop(1, '#e8c872');
|
| 2012 |
+
ctx.fillStyle = sand; ctx.fillRect(0, h*0.55, w, h*0.45);
|
| 2013 |
+
// Palm tree
|
| 2014 |
+
ctx.fillStyle = '#6b4226'; ctx.fillRect(w*0.12, h*0.15, w*0.025, h*0.5);
|
| 2015 |
+
ctx.fillStyle = '#228b22';
|
| 2016 |
+
for (let a = -0.5; a < 2.7; a += 0.5) {
|
| 2017 |
+
ctx.save(); ctx.translate(w*0.133, h*0.15); ctx.rotate(a);
|
| 2018 |
+
ctx.beginPath(); ctx.ellipse(0, -h*0.08, w*0.06, h*0.02, 0, 0, Math.PI*2); ctx.fill();
|
| 2019 |
+
ctx.restore();
|
| 2020 |
+
}
|
| 2021 |
+
// Wave lines
|
| 2022 |
+
ctx.strokeStyle = 'rgba(255,255,255,0.3)'; ctx.lineWidth = 2;
|
| 2023 |
+
for (let i = 0; i < 3; i++) {
|
| 2024 |
+
ctx.beginPath();
|
| 2025 |
+
for (let x = 0; x < w; x += 4) ctx.lineTo(x, h*(0.42+i*0.05)+Math.sin(x/30+i)*5);
|
| 2026 |
+
ctx.stroke();
|
| 2027 |
+
}
|
| 2028 |
+
},
|
| 2029 |
+
mountain: (ctx, w, h) => {
|
| 2030 |
+
// Snow-capped mountains
|
| 2031 |
+
const sky = ctx.createLinearGradient(0, 0, 0, h*0.5);
|
| 2032 |
+
sky.addColorStop(0, '#1a1a3e'); sky.addColorStop(1, '#4a3f6b');
|
| 2033 |
+
ctx.fillStyle = sky; ctx.fillRect(0, 0, w, h*0.6);
|
| 2034 |
+
// Stars
|
| 2035 |
+
ctx.fillStyle = '#fff';
|
| 2036 |
+
for (let i = 0; i < 30; i++) {
|
| 2037 |
+
ctx.beginPath(); ctx.arc(Math.random()*w, Math.random()*h*0.4, 1, 0, Math.PI*2); ctx.fill();
|
| 2038 |
+
}
|
| 2039 |
+
// Mountains back
|
| 2040 |
+
ctx.fillStyle = '#3a3562';
|
| 2041 |
+
ctx.beginPath(); ctx.moveTo(0,h*0.55); ctx.lineTo(w*0.15,h*0.2); ctx.lineTo(w*0.35,h*0.5); ctx.lineTo(w*0.5,h*0.15); ctx.lineTo(w*0.7,h*0.45); ctx.lineTo(w*0.85,h*0.25); ctx.lineTo(w,h*0.4); ctx.lineTo(w,h*0.6); ctx.closePath(); ctx.fill();
|
| 2042 |
+
// Snow caps
|
| 2043 |
+
ctx.fillStyle = '#e8e8f0';
|
| 2044 |
+
ctx.beginPath(); ctx.moveTo(w*0.46,h*0.15); ctx.lineTo(w*0.5,h*0.15); ctx.lineTo(w*0.54,h*0.15); ctx.lineTo(w*0.52,h*0.22); ctx.lineTo(w*0.48,h*0.22); ctx.closePath(); ctx.fill();
|
| 2045 |
+
ctx.beginPath(); ctx.moveTo(w*0.13,h*0.2); ctx.lineTo(w*0.15,h*0.2); ctx.lineTo(w*0.17,h*0.2); ctx.lineTo(w*0.16,h*0.26); ctx.lineTo(w*0.14,h*0.26); ctx.closePath(); ctx.fill();
|
| 2046 |
+
// Forest
|
| 2047 |
+
ctx.fillStyle = '#1a3a25'; ctx.fillRect(0, h*0.52, w, h*0.12);
|
| 2048 |
+
// Lake
|
| 2049 |
+
const lake = ctx.createLinearGradient(0, h*0.6, 0, h);
|
| 2050 |
+
lake.addColorStop(0, '#2a4060'); lake.addColorStop(1, '#1a2a40');
|
| 2051 |
+
ctx.fillStyle = lake; ctx.fillRect(0, h*0.6, w, h*0.4);
|
| 2052 |
+
// Reflection
|
| 2053 |
+
ctx.fillStyle = 'rgba(90,70,120,.15)';
|
| 2054 |
+
ctx.beginPath(); ctx.moveTo(0,h*0.65); ctx.lineTo(w*0.5,h*0.85); ctx.lineTo(w,h*0.7); ctx.lineTo(w,h*0.62); ctx.lineTo(0,h*0.62); ctx.closePath(); ctx.fill();
|
| 2055 |
+
},
|
| 2056 |
+
city: (ctx, w, h) => {
|
| 2057 |
+
// City skyline at dusk
|
| 2058 |
+
const sky = ctx.createLinearGradient(0, 0, 0, h*0.6);
|
| 2059 |
+
sky.addColorStop(0, '#0f1626'); sky.addColorStop(1, '#2d1b4e');
|
| 2060 |
+
ctx.fillStyle = sky; ctx.fillRect(0, 0, w, h);
|
| 2061 |
+
// Stars
|
| 2062 |
+
ctx.fillStyle = '#fff';
|
| 2063 |
+
for (let i = 0; i < 20; i++) {
|
| 2064 |
+
ctx.beginPath(); ctx.arc(Math.random()*w, Math.random()*h*0.3, 0.8, 0, Math.PI*2); ctx.fill();
|
| 2065 |
+
}
|
| 2066 |
+
// Buildings
|
| 2067 |
+
const bColors = ['#1a1f35','#202540','#181d30','#252a45','#1e2338'];
|
| 2068 |
+
const bx = [0, 0.1, 0.2, 0.3, 0.42, 0.55, 0.62, 0.72, 0.82, 0.92];
|
| 2069 |
+
const bh = [0.4, 0.55, 0.35, 0.65, 0.5, 0.7, 0.3, 0.6, 0.45, 0.38];
|
| 2070 |
+
const bw2 = [0.1, 0.1, 0.1, 0.12, 0.13, 0.07, 0.1, 0.1, 0.1, 0.08];
|
| 2071 |
+
bx.forEach((x, i) => {
|
| 2072 |
+
ctx.fillStyle = bColors[i%5];
|
| 2073 |
+
ctx.fillRect(w*x, h*(1-bh[i]), w*bw2[i], h*bh[i]);
|
| 2074 |
+
// Windows
|
| 2075 |
+
ctx.fillStyle = '#ffd54f';
|
| 2076 |
+
for (let wy = 0.05; wy < bh[i]-0.05; wy += 0.06) {
|
| 2077 |
+
for (let wx = 0.02; wx < bw2[i]-0.02; wx += 0.03) {
|
| 2078 |
+
if (Math.random() > 0.35) ctx.fillRect(w*(x+wx), h*(1-bh[i]+wy), w*0.015, h*0.03);
|
| 2079 |
+
}
|
| 2080 |
+
}
|
| 2081 |
+
});
|
| 2082 |
+
// Road
|
| 2083 |
+
ctx.fillStyle = '#1a1a2e'; ctx.fillRect(0, h*0.88, w, h*0.12);
|
| 2084 |
+
ctx.strokeStyle = '#ffd54f'; ctx.lineWidth = 2; ctx.setLineDash([15,10]);
|
| 2085 |
+
ctx.beginPath(); ctx.moveTo(0, h*0.94); ctx.lineTo(w, h*0.94); ctx.stroke();
|
| 2086 |
+
ctx.setLineDash([]);
|
| 2087 |
+
},
|
| 2088 |
+
abstract: (ctx, w, h) => {
|
| 2089 |
+
// Modern abstract gradient (Teams-like)
|
| 2090 |
+
const bg = ctx.createLinearGradient(0, 0, w, h);
|
| 2091 |
+
bg.addColorStop(0, '#667eea'); bg.addColorStop(0.5, '#764ba2'); bg.addColorStop(1, '#f093fb');
|
| 2092 |
+
ctx.fillStyle = bg; ctx.fillRect(0, 0, w, h);
|
| 2093 |
+
// Circles
|
| 2094 |
+
ctx.globalAlpha = 0.15;
|
| 2095 |
+
ctx.fillStyle = '#fff';
|
| 2096 |
+
ctx.beginPath(); ctx.arc(w*0.2, h*0.3, w*0.2, 0, Math.PI*2); ctx.fill();
|
| 2097 |
+
ctx.beginPath(); ctx.arc(w*0.8, h*0.7, w*0.25, 0, Math.PI*2); ctx.fill();
|
| 2098 |
+
ctx.beginPath(); ctx.arc(w*0.5, h*0.1, w*0.15, 0, Math.PI*2); ctx.fill();
|
| 2099 |
+
ctx.globalAlpha = 0.08;
|
| 2100 |
+
ctx.beginPath(); ctx.arc(w*0.6, h*0.5, w*0.3, 0, Math.PI*2); ctx.fill();
|
| 2101 |
+
ctx.globalAlpha = 1;
|
| 2102 |
+
},
|
| 2103 |
+
classroom: (ctx, w, h) => {
|
| 2104 |
+
// Classroom with blackboard
|
| 2105 |
+
ctx.fillStyle = '#f0ebe0'; ctx.fillRect(0, 0, w, h);
|
| 2106 |
+
// Floor
|
| 2107 |
+
ctx.fillStyle = '#c4a87a'; ctx.fillRect(0, h*0.68, w, h*0.32);
|
| 2108 |
+
// Blackboard
|
| 2109 |
+
ctx.fillStyle = '#5a3e22'; ctx.fillRect(w*0.1, h*0.08, w*0.8, h*0.45);
|
| 2110 |
+
ctx.fillStyle = '#2a5a3a'; ctx.fillRect(w*0.12, h*0.1, w*0.76, h*0.41);
|
| 2111 |
+
// Chalk text lines
|
| 2112 |
+
ctx.strokeStyle = 'rgba(255,255,255,0.5)'; ctx.lineWidth = 1.5;
|
| 2113 |
+
for (let i = 0; i < 5; i++) {
|
| 2114 |
+
const y = h*(0.16+i*0.07);
|
| 2115 |
+
ctx.beginPath(); ctx.moveTo(w*0.16, y); ctx.lineTo(w*(0.4+Math.random()*0.3), y); ctx.stroke();
|
| 2116 |
+
}
|
| 2117 |
+
// Chalk tray
|
| 2118 |
+
ctx.fillStyle = '#5a3e22'; ctx.fillRect(w*0.12, h*0.5, w*0.76, h*0.03);
|
| 2119 |
+
// Desk
|
| 2120 |
+
ctx.fillStyle = '#8b6b4a';
|
| 2121 |
+
ctx.fillRect(w*0.2, h*0.62, w*0.6, h*0.04);
|
| 2122 |
+
ctx.fillRect(w*0.25, h*0.66, w*0.02, h*0.12);
|
| 2123 |
+
ctx.fillRect(w*0.73, h*0.66, w*0.02, h*0.12);
|
| 2124 |
+
// Clock
|
| 2125 |
+
ctx.fillStyle = '#fff'; ctx.beginPath(); ctx.arc(w*0.92, h*0.15, w*0.03, 0, Math.PI*2); ctx.fill();
|
| 2126 |
+
ctx.strokeStyle = '#333'; ctx.lineWidth = 1;
|
| 2127 |
+
ctx.beginPath(); ctx.arc(w*0.92, h*0.15, w*0.03, 0, Math.PI*2); ctx.stroke();
|
| 2128 |
+
},
|
| 2129 |
+
};
|
| 2130 |
+
|
| 2131 |
+
async function initSegmenter() {
|
| 2132 |
+
if (selfieSegmenter) return true;
|
| 2133 |
+
try {
|
| 2134 |
+
if (typeof SelfieSegmentation === 'undefined') {
|
| 2135 |
+
console.warn('SelfieSegmentation not available, using fallback mask');
|
| 2136 |
+
vbgUseFallback = true;
|
| 2137 |
+
return false;
|
| 2138 |
+
}
|
| 2139 |
+
showToast("Loading background model...");
|
| 2140 |
+
selfieSegmenter = new SelfieSegmentation({
|
| 2141 |
+
locateFile: (file) => `https://cdn.jsdelivr.net/npm/@mediapipe/selfie_segmentation/${file}`
|
| 2142 |
+
});
|
| 2143 |
+
selfieSegmenter.setOptions({ modelSelection: 1, selfieMode: true });
|
| 2144 |
+
selfieSegmenter.onResults((results) => {
|
| 2145 |
+
segMask = results.segmentationMask;
|
| 2146 |
+
});
|
| 2147 |
+
// Warm up with timeout
|
| 2148 |
+
const warmup = document.createElement('canvas');
|
| 2149 |
+
warmup.width = 4; warmup.height = 4;
|
| 2150 |
+
warmup.getContext('2d').fillRect(0, 0, 4, 4);
|
| 2151 |
+
const timeout = new Promise((_, rej) => setTimeout(() => rej(new Error('timeout')), 15000));
|
| 2152 |
+
await Promise.race([selfieSegmenter.send({ image: warmup }), timeout]);
|
| 2153 |
+
showToast("Background model ready");
|
| 2154 |
+
return true;
|
| 2155 |
+
} catch (e) {
|
| 2156 |
+
console.warn('Segmenter init failed, using fallback:', e);
|
| 2157 |
+
selfieSegmenter = null;
|
| 2158 |
+
vbgUseFallback = true;
|
| 2159 |
+
showToast("Using portrait mask (model unavailable)");
|
| 2160 |
+
return false;
|
| 2161 |
+
}
|
| 2162 |
+
}
|
| 2163 |
+
|
| 2164 |
+
function createFallbackMask(w, h) {
|
| 2165 |
+
const c = document.createElement('canvas');
|
| 2166 |
+
c.width = w; c.height = h;
|
| 2167 |
+
const ctx = c.getContext('2d');
|
| 2168 |
+
ctx.clearRect(0, 0, w, h);
|
| 2169 |
+
|
| 2170 |
+
// Soft body-shaped silhouette with feathered edges
|
| 2171 |
+
ctx.fillStyle = 'white';
|
| 2172 |
+
ctx.shadowColor = 'white';
|
| 2173 |
+
ctx.shadowBlur = 35;
|
| 2174 |
+
|
| 2175 |
+
// Head
|
| 2176 |
+
ctx.beginPath();
|
| 2177 |
+
ctx.ellipse(w * 0.5, h * 0.18, w * 0.11, h * 0.13, 0, 0, Math.PI * 2);
|
| 2178 |
+
ctx.fill();
|
| 2179 |
+
|
| 2180 |
+
// Neck + shoulders + torso (extends below frame)
|
| 2181 |
+
ctx.beginPath();
|
| 2182 |
+
ctx.moveTo(w * 0.43, h * 0.31);
|
| 2183 |
+
ctx.quadraticCurveTo(w * 0.36, h * 0.36, w * 0.12, h * 0.44);
|
| 2184 |
+
ctx.lineTo(w * 0.03, h * 0.56);
|
| 2185 |
+
ctx.lineTo(w * 0.03, h * 1.1);
|
| 2186 |
+
ctx.lineTo(w * 0.97, h * 1.1);
|
| 2187 |
+
ctx.lineTo(w * 0.97, h * 0.56);
|
| 2188 |
+
ctx.lineTo(w * 0.88, h * 0.44);
|
| 2189 |
+
ctx.quadraticCurveTo(w * 0.64, h * 0.36, w * 0.57, h * 0.31);
|
| 2190 |
+
ctx.closePath();
|
| 2191 |
+
ctx.fill();
|
| 2192 |
+
|
| 2193 |
+
ctx.shadowBlur = 0;
|
| 2194 |
+
return c;
|
| 2195 |
+
}
|
| 2196 |
+
|
| 2197 |
+
function vbgRenderLoop() {
|
| 2198 |
+
if (!bgBlurEnabled || !vbgTempVideo) return;
|
| 2199 |
+
const w = bgBlurCanvas.width, h = bgBlurCanvas.height;
|
| 2200 |
+
|
| 2201 |
+
const processFrame = () => {
|
| 2202 |
+
if (!bgBlurEnabled) return;
|
| 2203 |
+
|
| 2204 |
+
// Step 1: Draw video on person canvas
|
| 2205 |
+
vbgPersonCtx.clearRect(0, 0, w, h);
|
| 2206 |
+
vbgPersonCtx.drawImage(vbgTempVideo, 0, 0, w, h);
|
| 2207 |
+
|
| 2208 |
+
// Step 2: Apply mask to cut out person with transparent background
|
| 2209 |
+
if (segMask && !vbgUseFallback) {
|
| 2210 |
+
// MediaPipe mask: R channel = person confidence (white=person, black=bg)
|
| 2211 |
+
vbgMaskCtx.clearRect(0, 0, w, h);
|
| 2212 |
+
vbgMaskCtx.drawImage(segMask, 0, 0, w, h);
|
| 2213 |
+
const maskData = vbgMaskCtx.getImageData(0, 0, w, h);
|
| 2214 |
+
const md = maskData.data;
|
| 2215 |
+
const len = w * h;
|
| 2216 |
+
|
| 2217 |
+
// === A. Foreground-biased threshold + smoothstep ===
|
| 2218 |
+
// Shift uncertain pixels toward foreground so head/face aren't cut out
|
| 2219 |
+
const curMask = new Uint8Array(len);
|
| 2220 |
+
for (let p = 0; p < len; p++) {
|
| 2221 |
+
let v = md[p * 4] / 255;
|
| 2222 |
+
// Bias: boost values above 0.3 toward foreground
|
| 2223 |
+
v = Math.min(1, v * 1.4 + 0.08);
|
| 2224 |
+
// Smoothstep contrast curve
|
| 2225 |
+
v = v * v * (3 - 2 * v);
|
| 2226 |
+
// Conservative threshold: keep uncertain pixels as person
|
| 2227 |
+
curMask[p] = v > 0.35 ? ((v * 255 + 0.5) | 0) : 0;
|
| 2228 |
+
}
|
| 2229 |
+
|
| 2230 |
+
// === B. Morphological dilation (3x3) to fill gaps in head/shoulders ===
|
| 2231 |
+
const dilated = new Uint8Array(len);
|
| 2232 |
+
for (let y = 0; y < h; y++) {
|
| 2233 |
+
for (let x = 0; x < w; x++) {
|
| 2234 |
+
let maxVal = 0;
|
| 2235 |
+
for (let dy = -1; dy <= 1; dy++) {
|
| 2236 |
+
for (let dx = -1; dx <= 1; dx++) {
|
| 2237 |
+
const ny = y + dy, nx = x + dx;
|
| 2238 |
+
if (ny >= 0 && ny < h && nx >= 0 && nx < w) {
|
| 2239 |
+
const nv = curMask[ny * w + nx];
|
| 2240 |
+
if (nv > maxVal) maxVal = nv;
|
| 2241 |
+
}
|
| 2242 |
+
}
|
| 2243 |
+
}
|
| 2244 |
+
dilated[y * w + x] = maxVal;
|
| 2245 |
+
}
|
| 2246 |
+
}
|
| 2247 |
+
|
| 2248 |
+
// === C. Temporal smoothing (EMA) to prevent frame flicker ===
|
| 2249 |
+
if (!vbgPrevMask || vbgPrevMask.length !== len) {
|
| 2250 |
+
vbgPrevMask = dilated;
|
| 2251 |
+
} else {
|
| 2252 |
+
const alpha = 0.6; // current frame weight (lower = smoother but laggier)
|
| 2253 |
+
for (let p = 0; p < len; p++) {
|
| 2254 |
+
// Asymmetric blending: appearing is fast, disappearing is slow
|
| 2255 |
+
// This prevents face/head from vanishing on brief low-confidence frames
|
| 2256 |
+
const cur = dilated[p], prev = vbgPrevMask[p];
|
| 2257 |
+
const a = cur >= prev ? 0.75 : 0.4; // appear fast, disappear slow
|
| 2258 |
+
vbgPrevMask[p] = (a * cur + (1 - a) * prev + 0.5) | 0;
|
| 2259 |
+
}
|
| 2260 |
+
}
|
| 2261 |
+
|
| 2262 |
+
// === D. Write smoothed mask back as alpha ===
|
| 2263 |
+
for (let p = 0; p < len; p++) {
|
| 2264 |
+
const i4 = p * 4;
|
| 2265 |
+
md[i4] = md[i4 + 1] = md[i4 + 2] = 255;
|
| 2266 |
+
md[i4 + 3] = vbgPrevMask[p];
|
| 2267 |
+
}
|
| 2268 |
+
|
| 2269 |
+
// === E. Blur pass for soft feathered edges ===
|
| 2270 |
+
vbgTempMaskCtx.putImageData(maskData, 0, 0);
|
| 2271 |
+
vbgMaskCtx.clearRect(0, 0, w, h);
|
| 2272 |
+
vbgMaskCtx.filter = 'blur(5px)';
|
| 2273 |
+
vbgMaskCtx.drawImage(vbgTempMaskCanvas, 0, 0);
|
| 2274 |
+
vbgMaskCtx.filter = 'none';
|
| 2275 |
+
|
| 2276 |
+
// Cut person from video using soft alpha mask
|
| 2277 |
+
vbgPersonCtx.globalCompositeOperation = 'destination-in';
|
| 2278 |
+
vbgPersonCtx.drawImage(vbgMaskCanvas, 0, 0);
|
| 2279 |
+
vbgPersonCtx.globalCompositeOperation = 'source-over';
|
| 2280 |
+
} else if (vbgFallbackMask) {
|
| 2281 |
+
// Fallback: pre-rendered body silhouette already has correct alpha
|
| 2282 |
+
vbgPersonCtx.globalCompositeOperation = 'destination-in';
|
| 2283 |
+
vbgPersonCtx.drawImage(vbgFallbackMask, 0, 0);
|
| 2284 |
+
vbgPersonCtx.globalCompositeOperation = 'source-over';
|
| 2285 |
+
}
|
| 2286 |
+
|
| 2287 |
+
// Step 3: Compose β background first, then person on top
|
| 2288 |
+
bgBlurCtx.clearRect(0, 0, w, h);
|
| 2289 |
+
if (vbgMode === 'blur') {
|
| 2290 |
+
bgBlurCtx.filter = 'blur(12px)';
|
| 2291 |
+
bgBlurCtx.drawImage(vbgTempVideo, 0, 0, w, h);
|
| 2292 |
+
bgBlurCtx.filter = 'none';
|
| 2293 |
+
} else if (vbgSceneBg) {
|
| 2294 |
+
bgBlurCtx.drawImage(vbgSceneBg, 0, 0, w, h);
|
| 2295 |
+
}
|
| 2296 |
+
bgBlurCtx.drawImage(vbgPersonCanvas, 0, 0);
|
| 2297 |
+
|
| 2298 |
+
requestAnimationFrame(vbgRenderLoop);
|
| 2299 |
+
};
|
| 2300 |
+
|
| 2301 |
+
// Send frame to segmenter if available, otherwise use fallback directly
|
| 2302 |
+
if (selfieSegmenter && !vbgUseFallback) {
|
| 2303 |
+
selfieSegmenter.send({ image: vbgTempVideo }).then(processFrame).catch(() => {
|
| 2304 |
+
processFrame(); // Use last known mask or fallback
|
| 2305 |
+
});
|
| 2306 |
+
} else {
|
| 2307 |
+
processFrame();
|
| 2308 |
+
}
|
| 2309 |
+
}
|
| 2310 |
+
|
| 2311 |
+
function startVbgPipeline(mode, sceneBgCanvas) {
|
| 2312 |
+
if (!localStream) return;
|
| 2313 |
+
const videoTrack = localStream.getVideoTracks()[0];
|
| 2314 |
+
if (!videoTrack) return;
|
| 2315 |
+
const w = 640, h = 480;
|
| 2316 |
+
|
| 2317 |
+
bgBlurCanvas = document.createElement('canvas');
|
| 2318 |
+
bgBlurCanvas.width = w; bgBlurCanvas.height = h;
|
| 2319 |
+
bgBlurCtx = bgBlurCanvas.getContext('2d');
|
| 2320 |
+
|
| 2321 |
+
vbgPersonCanvas = document.createElement('canvas');
|
| 2322 |
+
vbgPersonCanvas.width = w; vbgPersonCanvas.height = h;
|
| 2323 |
+
vbgPersonCtx = vbgPersonCanvas.getContext('2d');
|
| 2324 |
+
|
| 2325 |
+
vbgMaskCanvas = document.createElement('canvas');
|
| 2326 |
+
vbgMaskCanvas.width = w; vbgMaskCanvas.height = h;
|
| 2327 |
+
vbgMaskCtx = vbgMaskCanvas.getContext('2d');
|
| 2328 |
+
|
| 2329 |
+
vbgTempMaskCanvas = document.createElement('canvas');
|
| 2330 |
+
vbgTempMaskCanvas.width = w; vbgTempMaskCanvas.height = h;
|
| 2331 |
+
vbgTempMaskCtx = vbgTempMaskCanvas.getContext('2d');
|
| 2332 |
+
|
| 2333 |
+
if (vbgUseFallback && !vbgFallbackMask) {
|
| 2334 |
+
vbgFallbackMask = createFallbackMask(w, h);
|
| 2335 |
+
}
|
| 2336 |
+
|
| 2337 |
+
bgBlurEnabled = true;
|
| 2338 |
+
vbgMode = mode;
|
| 2339 |
+
vbgSceneBg = sceneBgCanvas || null;
|
| 2340 |
+
|
| 2341 |
+
vbgTempVideo = document.createElement('video');
|
| 2342 |
+
vbgTempVideo.srcObject = new MediaStream([videoTrack]);
|
| 2343 |
+
vbgTempVideo.muted = true;
|
| 2344 |
+
vbgTempVideo.addEventListener('loadeddata', () => {
|
| 2345 |
+
vbgRenderLoop();
|
| 2346 |
+
});
|
| 2347 |
+
vbgTempVideo.play();
|
| 2348 |
+
|
| 2349 |
+
bgBlurStream = bgBlurCanvas.captureStream(30);
|
| 2350 |
+
const bgTrack = bgBlurStream.getVideoTracks()[0];
|
| 2351 |
+
for (const pid in peerConnections) {
|
| 2352 |
+
const sender = peerConnections[pid].pc.getSenders().find(s => s.track?.kind === 'video');
|
| 2353 |
+
if (sender) sender.replaceTrack(bgTrack);
|
| 2354 |
+
}
|
| 2355 |
+
localVideo.srcObject = bgBlurStream;
|
| 2356 |
+
}
|
| 2357 |
+
|
| 2358 |
+
function generateVbgThumbnails() {
|
| 2359 |
+
for (const [scene, drawFn] of Object.entries(VBG_SCENES)) {
|
| 2360 |
+
const el = document.getElementById('vbgPreview' + scene.charAt(0).toUpperCase() + scene.slice(1));
|
| 2361 |
+
if (!el) continue;
|
| 2362 |
+
const c = document.createElement('canvas');
|
| 2363 |
+
c.width = 80; c.height = 50;
|
| 2364 |
+
const ctx = c.getContext('2d');
|
| 2365 |
+
drawFn(ctx, 80, 50);
|
| 2366 |
+
el.appendChild(c);
|
| 2367 |
+
}
|
| 2368 |
+
}
|
| 2369 |
+
|
| 2370 |
+
function openVirtualBgModal() {
|
| 2371 |
+
const modal = document.getElementById("vbgModal");
|
| 2372 |
+
modal.style.display = "flex";
|
| 2373 |
+
// Generate thumbnails on first open
|
| 2374 |
+
if (!modal._thumbsGenerated) {
|
| 2375 |
+
generateVbgThumbnails();
|
| 2376 |
+
modal._thumbsGenerated = true;
|
| 2377 |
+
}
|
| 2378 |
+
modal.querySelectorAll(".vbg-option").forEach(opt => {
|
| 2379 |
+
opt.classList.toggle("active", opt.dataset.bg === currentVbg);
|
| 2380 |
+
});
|
| 2381 |
+
}
|
| 2382 |
+
|
| 2383 |
+
async function applyVirtualBg(bgValue) {
|
| 2384 |
+
currentVbg = bgValue;
|
| 2385 |
+
// Clean up existing
|
| 2386 |
+
if (bgBlurStream) {
|
| 2387 |
+
bgBlurStream.getTracks().forEach(t => t.stop());
|
| 2388 |
+
bgBlurStream = null;
|
| 2389 |
+
}
|
| 2390 |
+
bgBlurEnabled = false;
|
| 2391 |
+
vbgTempVideo = null;
|
| 2392 |
+
vbgSceneBg = null;
|
| 2393 |
+
vbgMode = null;
|
| 2394 |
+
vbgPrevMask = null; // Reset temporal buffer
|
| 2395 |
+
|
| 2396 |
+
if (bgValue === "none") {
|
| 2397 |
+
const camTrack = localStream ? localStream.getVideoTracks()[0] : null;
|
| 2398 |
+
for (const pid in peerConnections) {
|
| 2399 |
+
const sender = peerConnections[pid].pc.getSenders().find(s => s.track?.kind === "video");
|
| 2400 |
+
if (sender && camTrack) sender.replaceTrack(camTrack);
|
| 2401 |
+
}
|
| 2402 |
+
localVideo.srcObject = localStream;
|
| 2403 |
+
showToast("Background removed");
|
| 2404 |
+
return;
|
| 2405 |
+
}
|
| 2406 |
+
|
| 2407 |
+
// Init segmentation model on first use
|
| 2408 |
+
await initSegmenter();
|
| 2409 |
+
|
| 2410 |
+
if (bgValue === "blur") {
|
| 2411 |
+
startVbgPipeline('blur');
|
| 2412 |
+
showToast("Background blur on");
|
| 2413 |
+
return;
|
| 2414 |
+
}
|
| 2415 |
+
|
| 2416 |
+
// Scene background
|
| 2417 |
+
if (bgValue.startsWith("scene:")) {
|
| 2418 |
+
const sceneKey = bgValue.split(":")[1];
|
| 2419 |
+
const drawFn = VBG_SCENES[sceneKey];
|
| 2420 |
+
if (!drawFn || !localStream) return;
|
| 2421 |
+
|
| 2422 |
+
const sceneBg = document.createElement('canvas');
|
| 2423 |
+
sceneBg.width = 640; sceneBg.height = 480;
|
| 2424 |
+
drawFn(sceneBg.getContext('2d'), 640, 480);
|
| 2425 |
+
|
| 2426 |
+
startVbgPipeline('scene', sceneBg);
|
| 2427 |
+
showToast("Virtual background applied");
|
| 2428 |
+
return;
|
| 2429 |
+
}
|
| 2430 |
+
}
|
| 2431 |
+
|
| 2432 |
+
// ββ Keyboard Shortcuts ββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 2433 |
+
function setupKeyboardShortcuts() {
|
| 2434 |
+
document.addEventListener("keydown", (e) => {
|
| 2435 |
+
// Don't trigger if typing in input/textarea
|
| 2436 |
+
if (e.target.tagName === "INPUT" || e.target.tagName === "TEXTAREA" || e.target.tagName === "SELECT") return;
|
| 2437 |
+
if (!callScreen.classList.contains("active")) return;
|
| 2438 |
+
|
| 2439 |
+
switch (e.key.toLowerCase()) {
|
| 2440 |
+
case "m": toggleMic(); break;
|
| 2441 |
+
case "v": toggleCam(); break;
|
| 2442 |
+
case "s": toggleScreenShare(); break;
|
| 2443 |
+
case "h": toggleHandRaise(); break;
|
| 2444 |
+
case "c":
|
| 2445 |
+
chatOpen = !chatOpen;
|
| 2446 |
+
chatPanel.classList.toggle("open", chatOpen);
|
| 2447 |
+
chatBtn.classList.toggle("active", chatOpen);
|
| 2448 |
+
if (chatOpen) { closeSidePanels("chatPanel"); chatInput.focus(); }
|
| 2449 |
+
break;
|
| 2450 |
+
case "r": toggleRecording(); break;
|
| 2451 |
+
case "g": toggleViewMode(); break;
|
| 2452 |
+
case "f":
|
| 2453 |
+
if (!document.fullscreenElement) {
|
| 2454 |
+
document.documentElement.requestFullscreen().catch(() => {});
|
| 2455 |
+
} else {
|
| 2456 |
+
document.exitFullscreen().catch(() => {});
|
| 2457 |
+
}
|
| 2458 |
+
break;
|
| 2459 |
+
case "?": document.getElementById("shortcutsModal").style.display = "flex"; break;
|
| 2460 |
+
case "escape":
|
| 2461 |
+
// Close any open modal
|
| 2462 |
+
document.querySelectorAll(".modal-overlay").forEach(m => m.style.display = "none");
|
| 2463 |
+
break;
|
| 2464 |
+
}
|
| 2465 |
+
});
|
| 2466 |
+
}
|
static/index.html
CHANGED
|
@@ -7,6 +7,7 @@
|
|
| 7 |
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
| 8 |
<link href="https://fonts.googleapis.com/icon?family=Material+Icons+Round" rel="stylesheet">
|
| 9 |
<link rel="stylesheet" href="/static/styles.css">
|
|
|
|
| 10 |
</head>
|
| 11 |
<body>
|
| 12 |
<!-- Landing / Join Screen -->
|
|
@@ -203,6 +204,7 @@
|
|
| 203 |
<span class="room-info" id="roomInfo"></span>
|
| 204 |
<button id="copyLinkBtn" class="text-btn" title="Copy invite link"><span class="material-icons-round">content_copy</span> Copy link</button>
|
| 205 |
<span class="meeting-timer" id="meetingTimer">00:00</span>
|
|
|
|
| 206 |
</div>
|
| 207 |
<div class="controls-center">
|
| 208 |
<button id="micBtn" class="ctrl-btn active" title="Toggle microphone">
|
|
@@ -260,6 +262,9 @@
|
|
| 260 |
<button id="breakoutBtn" class="dropdown-item"><span class="material-icons-round">dashboard</span> Breakout Rooms</button>
|
| 261 |
<button id="notesBtn" class="dropdown-item"><span class="material-icons-round">description</span> Meeting Notes</button>
|
| 262 |
<button id="bgBlurBtn" class="dropdown-item"><span class="material-icons-round">blur_on</span> Background Blur</button>
|
|
|
|
|
|
|
|
|
|
| 263 |
</div>
|
| 264 |
</div>
|
| 265 |
|
|
@@ -275,6 +280,56 @@
|
|
| 275 |
|
| 276 |
<div class="toast" id="toast"></div>
|
| 277 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 278 |
<script src="/static/app.js"></script>
|
| 279 |
</body>
|
| 280 |
</html>
|
|
|
|
| 7 |
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
| 8 |
<link href="https://fonts.googleapis.com/icon?family=Material+Icons+Round" rel="stylesheet">
|
| 9 |
<link rel="stylesheet" href="/static/styles.css">
|
| 10 |
+
<script src="https://cdn.jsdelivr.net/npm/@mediapipe/selfie_segmentation/selfie_segmentation.js" crossorigin="anonymous"></script>
|
| 11 |
</head>
|
| 12 |
<body>
|
| 13 |
<!-- Landing / Join Screen -->
|
|
|
|
| 204 |
<span class="room-info" id="roomInfo"></span>
|
| 205 |
<button id="copyLinkBtn" class="text-btn" title="Copy invite link"><span class="material-icons-round">content_copy</span> Copy link</button>
|
| 206 |
<span class="meeting-timer" id="meetingTimer">00:00</span>
|
| 207 |
+
<button id="viewToggleBtn" class="text-btn" title="Toggle view"><span class="material-icons-round">grid_view</span> <span id="viewToggleLabel">Gallery</span></button>
|
| 208 |
</div>
|
| 209 |
<div class="controls-center">
|
| 210 |
<button id="micBtn" class="ctrl-btn active" title="Toggle microphone">
|
|
|
|
| 262 |
<button id="breakoutBtn" class="dropdown-item"><span class="material-icons-round">dashboard</span> Breakout Rooms</button>
|
| 263 |
<button id="notesBtn" class="dropdown-item"><span class="material-icons-round">description</span> Meeting Notes</button>
|
| 264 |
<button id="bgBlurBtn" class="dropdown-item"><span class="material-icons-round">blur_on</span> Background Blur</button>
|
| 265 |
+
<button id="virtualBgBtn" class="dropdown-item"><span class="material-icons-round">wallpaper</span> Virtual Background</button>
|
| 266 |
+
<button id="deviceSelectBtn" class="dropdown-item"><span class="material-icons-round">settings</span> Audio/Video Settings</button>
|
| 267 |
+
<button id="shortcutsBtn" class="dropdown-item"><span class="material-icons-round">keyboard</span> Keyboard Shortcuts</button>
|
| 268 |
</div>
|
| 269 |
</div>
|
| 270 |
|
|
|
|
| 280 |
|
| 281 |
<div class="toast" id="toast"></div>
|
| 282 |
|
| 283 |
+
<!-- Device Selector Modal -->
|
| 284 |
+
<div class="modal-overlay" id="deviceModal" style="display:none">
|
| 285 |
+
<div class="modal-card">
|
| 286 |
+
<div class="modal-header"><h3>Audio & Video Settings</h3><button class="icon-btn" id="closeDeviceModal">β</button></div>
|
| 287 |
+
<div class="modal-body">
|
| 288 |
+
<label>Camera<select id="camSelect"></select></label>
|
| 289 |
+
<label>Microphone<select id="micSelect"></select></label>
|
| 290 |
+
<label>Speaker<select id="speakerSelect"></select></label>
|
| 291 |
+
</div>
|
| 292 |
+
</div>
|
| 293 |
+
</div>
|
| 294 |
+
|
| 295 |
+
<!-- Virtual Background Modal -->
|
| 296 |
+
<div class="modal-overlay" id="vbgModal" style="display:none">
|
| 297 |
+
<div class="modal-card" style="max-width:520px">
|
| 298 |
+
<div class="modal-header"><h3>Virtual Background</h3><button class="icon-btn" id="closeVbgModal">β</button></div>
|
| 299 |
+
<div class="modal-body vbg-grid">
|
| 300 |
+
<div class="vbg-option active" data-bg="none" title="None"><span class="material-icons-round">close</span><span>None</span></div>
|
| 301 |
+
<div class="vbg-option" data-bg="blur" title="Blur"><span class="material-icons-round">blur_on</span><span>Blur</span></div>
|
| 302 |
+
<div class="vbg-option" data-bg="scene:office" title="Office"><div class="vbg-preview" id="vbgPreviewOffice"></div><span>Office</span></div>
|
| 303 |
+
<div class="vbg-option" data-bg="scene:livingroom" title="Living Room"><div class="vbg-preview" id="vbgPreviewLivingroom"></div><span>Living Room</span></div>
|
| 304 |
+
<div class="vbg-option" data-bg="scene:nature" title="Nature"><div class="vbg-preview" id="vbgPreviewNature"></div><span>Nature</span></div>
|
| 305 |
+
<div class="vbg-option" data-bg="scene:beach" title="Beach"><div class="vbg-preview" id="vbgPreviewBeach"></div><span>Beach</span></div>
|
| 306 |
+
<div class="vbg-option" data-bg="scene:mountain" title="Mountain"><div class="vbg-preview" id="vbgPreviewMountain"></div><span>Mountain</span></div>
|
| 307 |
+
<div class="vbg-option" data-bg="scene:city" title="City Night"><div class="vbg-preview" id="vbgPreviewCity"></div><span>City Night</span></div>
|
| 308 |
+
<div class="vbg-option" data-bg="scene:abstract" title="Abstract"><div class="vbg-preview" id="vbgPreviewAbstract"></div><span>Abstract</span></div>
|
| 309 |
+
<div class="vbg-option" data-bg="scene:classroom" title="Classroom"><div class="vbg-preview" id="vbgPreviewClassroom"></div><span>Classroom</span></div>
|
| 310 |
+
</div>
|
| 311 |
+
</div>
|
| 312 |
+
</div>
|
| 313 |
+
|
| 314 |
+
<!-- Keyboard Shortcuts Modal -->
|
| 315 |
+
<div class="modal-overlay" id="shortcutsModal" style="display:none">
|
| 316 |
+
<div class="modal-card">
|
| 317 |
+
<div class="modal-header"><h3>Keyboard Shortcuts</h3><button class="icon-btn" id="closeShortcutsModal">β</button></div>
|
| 318 |
+
<div class="modal-body shortcuts-list">
|
| 319 |
+
<div class="shortcut-row"><kbd>M</kbd><span>Toggle microphone</span></div>
|
| 320 |
+
<div class="shortcut-row"><kbd>V</kbd><span>Toggle camera</span></div>
|
| 321 |
+
<div class="shortcut-row"><kbd>S</kbd><span>Toggle screen share</span></div>
|
| 322 |
+
<div class="shortcut-row"><kbd>H</kbd><span>Raise / lower hand</span></div>
|
| 323 |
+
<div class="shortcut-row"><kbd>C</kbd><span>Toggle chat</span></div>
|
| 324 |
+
<div class="shortcut-row"><kbd>R</kbd><span>Toggle recording</span></div>
|
| 325 |
+
<div class="shortcut-row"><kbd>G</kbd><span>Toggle gallery / speaker view</span></div>
|
| 326 |
+
<div class="shortcut-row"><kbd>F</kbd><span>Toggle fullscreen</span></div>
|
| 327 |
+
<div class="shortcut-row"><kbd>Esc</kbd><span>Leave call / close modal</span></div>
|
| 328 |
+
<div class="shortcut-row"><kbd>?</kbd><span>Show shortcuts</span></div>
|
| 329 |
+
</div>
|
| 330 |
+
</div>
|
| 331 |
+
</div>
|
| 332 |
+
|
| 333 |
<script src="/static/app.js"></script>
|
| 334 |
</body>
|
| 335 |
</html>
|
static/styles.css
CHANGED
|
@@ -1187,3 +1187,180 @@ input[type="text"]::placeholder {
|
|
| 1187 |
.controls-center { gap: 4px; }
|
| 1188 |
.ctrl-dropdown .dropdown-menu { min-width: 160px; }
|
| 1189 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1187 |
.controls-center { gap: 4px; }
|
| 1188 |
.ctrl-dropdown .dropdown-menu { min-width: 160px; }
|
| 1189 |
}
|
| 1190 |
+
|
| 1191 |
+
/* βββ Speaker Active Indicator βββββββββββββββββββββββββββββ */
|
| 1192 |
+
.video-tile.speaking {
|
| 1193 |
+
box-shadow: 0 0 0 3px var(--blue-600), 0 0 12px rgba(26,115,232,0.3);
|
| 1194 |
+
}
|
| 1195 |
+
.video-tile.speaking .tile-label .mic-indicator {
|
| 1196 |
+
color: var(--blue-600);
|
| 1197 |
+
}
|
| 1198 |
+
|
| 1199 |
+
/* βββ Pin Button βββββββββββββββββββββββββββββββββββββββββββ */
|
| 1200 |
+
.pin-btn {
|
| 1201 |
+
position: absolute;
|
| 1202 |
+
top: 8px;
|
| 1203 |
+
right: 8px;
|
| 1204 |
+
width: 32px;
|
| 1205 |
+
height: 32px;
|
| 1206 |
+
border-radius: 50%;
|
| 1207 |
+
background: rgba(0,0,0,0.5);
|
| 1208 |
+
border: none;
|
| 1209 |
+
color: #fff;
|
| 1210 |
+
cursor: pointer;
|
| 1211 |
+
display: flex;
|
| 1212 |
+
align-items: center;
|
| 1213 |
+
justify-content: center;
|
| 1214 |
+
opacity: 0;
|
| 1215 |
+
transition: opacity var(--transition), background var(--transition);
|
| 1216 |
+
z-index: 5;
|
| 1217 |
+
}
|
| 1218 |
+
.pin-btn .material-icons-round { font-size: 18px; }
|
| 1219 |
+
.video-tile:hover .pin-btn { opacity: 1; }
|
| 1220 |
+
.pin-btn:hover { background: rgba(0,0,0,0.7); }
|
| 1221 |
+
.pin-btn.active {
|
| 1222 |
+
opacity: 1;
|
| 1223 |
+
background: var(--blue-600);
|
| 1224 |
+
}
|
| 1225 |
+
|
| 1226 |
+
/* βββ View Modes βββββββββββββββββββββββββββββββββββββββββββ */
|
| 1227 |
+
.view-speaker {
|
| 1228 |
+
display: grid !important;
|
| 1229 |
+
grid-template-columns: 1fr;
|
| 1230 |
+
grid-template-rows: 1fr auto;
|
| 1231 |
+
gap: 8px;
|
| 1232 |
+
}
|
| 1233 |
+
.view-speaker .video-tile {
|
| 1234 |
+
max-height: 120px;
|
| 1235 |
+
max-width: 180px;
|
| 1236 |
+
}
|
| 1237 |
+
.view-speaker .video-tile.spotlight {
|
| 1238 |
+
grid-column: 1;
|
| 1239 |
+
grid-row: 1;
|
| 1240 |
+
max-height: unset;
|
| 1241 |
+
max-width: unset;
|
| 1242 |
+
width: 100%;
|
| 1243 |
+
height: 100%;
|
| 1244 |
+
}
|
| 1245 |
+
|
| 1246 |
+
/* βββ Modal Overlay ββββββββββββββββββββββββββββββββββββββββ */
|
| 1247 |
+
.modal-overlay {
|
| 1248 |
+
position: fixed;
|
| 1249 |
+
inset: 0;
|
| 1250 |
+
background: rgba(0,0,0,0.4);
|
| 1251 |
+
z-index: 100;
|
| 1252 |
+
display: flex;
|
| 1253 |
+
align-items: center;
|
| 1254 |
+
justify-content: center;
|
| 1255 |
+
}
|
| 1256 |
+
.modal-card {
|
| 1257 |
+
background: var(--surface);
|
| 1258 |
+
border: 1px solid var(--hairline);
|
| 1259 |
+
border-radius: var(--radius-lg);
|
| 1260 |
+
box-shadow: var(--elevation-3);
|
| 1261 |
+
width: 90%;
|
| 1262 |
+
max-width: 420px;
|
| 1263 |
+
max-height: 80vh;
|
| 1264 |
+
overflow-y: auto;
|
| 1265 |
+
}
|
| 1266 |
+
.modal-header {
|
| 1267 |
+
display: flex;
|
| 1268 |
+
align-items: center;
|
| 1269 |
+
justify-content: space-between;
|
| 1270 |
+
padding: 16px 20px;
|
| 1271 |
+
border-bottom: 1px solid var(--hairline);
|
| 1272 |
+
}
|
| 1273 |
+
.modal-header h3 {
|
| 1274 |
+
font-size: 16px;
|
| 1275 |
+
font-weight: 600;
|
| 1276 |
+
}
|
| 1277 |
+
.modal-body {
|
| 1278 |
+
padding: 16px 20px;
|
| 1279 |
+
}
|
| 1280 |
+
.modal-body label {
|
| 1281 |
+
display: flex;
|
| 1282 |
+
flex-direction: column;
|
| 1283 |
+
gap: 6px;
|
| 1284 |
+
font-size: 13px;
|
| 1285 |
+
font-weight: 500;
|
| 1286 |
+
color: var(--text-secondary);
|
| 1287 |
+
margin-bottom: 14px;
|
| 1288 |
+
}
|
| 1289 |
+
.modal-body select {
|
| 1290 |
+
padding: 8px 10px;
|
| 1291 |
+
border: 1px solid var(--hairline);
|
| 1292 |
+
border-radius: var(--radius-sm);
|
| 1293 |
+
font-size: 13px;
|
| 1294 |
+
font-family: inherit;
|
| 1295 |
+
background: var(--surface-alt);
|
| 1296 |
+
color: var(--text-primary);
|
| 1297 |
+
outline: none;
|
| 1298 |
+
}
|
| 1299 |
+
.modal-body select:focus {
|
| 1300 |
+
border-color: var(--blue-600);
|
| 1301 |
+
}
|
| 1302 |
+
|
| 1303 |
+
/* βββ Virtual Background Grid ββββββββββββββββββββββββββββββ */
|
| 1304 |
+
.vbg-grid {
|
| 1305 |
+
display: grid;
|
| 1306 |
+
grid-template-columns: repeat(5, 1fr);
|
| 1307 |
+
gap: 10px;
|
| 1308 |
+
}
|
| 1309 |
+
.vbg-option {
|
| 1310 |
+
display: flex;
|
| 1311 |
+
flex-direction: column;
|
| 1312 |
+
align-items: center;
|
| 1313 |
+
gap: 4px;
|
| 1314 |
+
padding: 10px 6px;
|
| 1315 |
+
border: 2px solid var(--hairline);
|
| 1316 |
+
border-radius: var(--radius-sm);
|
| 1317 |
+
cursor: pointer;
|
| 1318 |
+
transition: border-color var(--transition), background var(--transition);
|
| 1319 |
+
font-size: 11px;
|
| 1320 |
+
color: var(--text-secondary);
|
| 1321 |
+
}
|
| 1322 |
+
.vbg-option:hover { border-color: var(--blue-600); background: var(--surface-alt); }
|
| 1323 |
+
.vbg-option.active { border-color: var(--blue-600); background: rgba(26,115,232,.08); }
|
| 1324 |
+
.vbg-option .material-icons-round { font-size: 28px; color: var(--text-hint); }
|
| 1325 |
+
.vbg-preview {
|
| 1326 |
+
width: 72px;
|
| 1327 |
+
height: 46px;
|
| 1328 |
+
border-radius: var(--radius-sm);
|
| 1329 |
+
overflow: hidden;
|
| 1330 |
+
display: flex;
|
| 1331 |
+
align-items: center;
|
| 1332 |
+
justify-content: center;
|
| 1333 |
+
}
|
| 1334 |
+
.vbg-preview canvas {
|
| 1335 |
+
width: 100%;
|
| 1336 |
+
height: 100%;
|
| 1337 |
+
display: block;
|
| 1338 |
+
}
|
| 1339 |
+
|
| 1340 |
+
/* βββ Keyboard Shortcuts List ββββββββββββββββββββββββββββββ */
|
| 1341 |
+
.shortcuts-list {
|
| 1342 |
+
display: flex;
|
| 1343 |
+
flex-direction: column;
|
| 1344 |
+
gap: 10px;
|
| 1345 |
+
}
|
| 1346 |
+
.shortcut-row {
|
| 1347 |
+
display: flex;
|
| 1348 |
+
align-items: center;
|
| 1349 |
+
gap: 12px;
|
| 1350 |
+
font-size: 13px;
|
| 1351 |
+
}
|
| 1352 |
+
.shortcut-row kbd {
|
| 1353 |
+
min-width: 36px;
|
| 1354 |
+
padding: 4px 10px;
|
| 1355 |
+
background: var(--surface-alt);
|
| 1356 |
+
border: 1px solid var(--hairline);
|
| 1357 |
+
border-radius: 6px;
|
| 1358 |
+
font-family: 'Segoe UI', monospace;
|
| 1359 |
+
font-size: 12px;
|
| 1360 |
+
font-weight: 600;
|
| 1361 |
+
text-align: center;
|
| 1362 |
+
color: var(--text-primary);
|
| 1363 |
+
}
|
| 1364 |
+
.shortcut-row span {
|
| 1365 |
+
color: var(--text-secondary);
|
| 1366 |
+
}
|