From 2429ea2ad8056fc105d39e2d2d24a54ab7bf1127 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Mon, 13 Apr 2020 10:25:39 +0200 Subject: [PATCH] Can toggle camera visibility --- assets/js/components/calls/window.js | 33 ++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/assets/js/components/calls/window.js b/assets/js/components/calls/window.js index 8f850eee..3b739bfd 100644 --- a/assets/js/components/calls/window.js +++ b/assets/js/components/calls/window.js @@ -109,6 +109,15 @@ class CallWindow extends CustomEvents { // Display the list of buttons const buttonsList = [ + // Toggle current user camera + { + icon: "fa-eye", + selected: true, + onclick: (btn) => { + setButtonSelected(btn, this.toggleMainStreamVisibility()) + } + }, + // Audio button { icon: "fa-microphone", @@ -475,6 +484,30 @@ class CallWindow extends CustomEvents { this.refreshButtonsState() } + /** + * Toggle current peer stream visibility + * + * @return {boolean} New state + */ + toggleMainStreamVisibility() { + const el = this.videoEls.get(userID()) + + if(!el || el.nodeName !== "VIDEO") + return true; + + // Show again element + if(el.parentNode.style.display == "none") { + el.parentNode.style.display = "" + return true + } + + // Hide element + else { + el.parentNode.style.display = "none" + return false + } + } + /** * Add audio / video stream to the user *