From 6fc3c506d40b4fdcd3331ecb404fda9aa568afae Mon Sep 17 00:00:00 2001 From: Miroslav Pejic Date: Sun, 10 Apr 2022 19:13:22 +0200 Subject: [PATCH] [mirotalksfu] - add toggle both audio & video on join --- public/js/Room.js | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/public/js/Room.js b/public/js/Room.js index dd684ba1..e4124255 100644 --- a/public/js/Room.js +++ b/public/js/Room.js @@ -42,9 +42,11 @@ let peer_info = null; let isEnumerateDevices = false; let isAudioAllowed = false; let isVideoAllowed = false; +let isAudioVideoAllowed = false; let isScreenAllowed = false; let initAudioButton = null; let initVideoButton = null; +let initAudioVideoButton = null; let recTimer = null; let recElapsedTime = null; @@ -313,6 +315,7 @@ function whoAreYou() {
+
`, confirmButtonText: `Join meeting`, showClass: { @@ -334,12 +337,15 @@ function whoAreYou() { if (!DetectRTC.isMobileDevice) { setTippy('initAudioButton', 'Toggle the audio', 'left'); setTippy('initVideoButton', 'Toggle the video', 'right'); + setTippy('initAudioVideoButton', 'Toggle the audio & video', 'right'); } initAudioButton = document.getElementById('initAudioButton'); initVideoButton = document.getElementById('initVideoButton'); - if (!isAudioAllowed) initAudioButton.className = 'hidden'; - if (!isVideoAllowed) initVideoButton.className = 'hidden'; + initAudioVideoButton = document.getElementById('initAudioVideoButton'); + if (!isAudioAllowed) hide(initAudioButton); + if (!isVideoAllowed) hide(initVideoButton); + if (!isAudioAllowed || !isVideoAllowed) hide(initAudioVideoButton); } function handleAudio(e) { @@ -356,6 +362,25 @@ function handleVideo(e) { setColor(startVideoButton, isVideoAllowed ? 'white' : 'red'); } +function handleAudioVideo(e) { + isAudioAllowed = isAudioAllowed ? false : true; + isVideoAllowed = isVideoAllowed ? false : true; + isAudioVideoAllowed = isAudioAllowed && isVideoAllowed; + if (isAudioVideoAllowed) { + initAudioButton.className = 'fas fa-microphone'; + initVideoButton.className = 'fas fa-video'; + } else { + hide(initAudioButton); + hide(initVideoButton); + } + e.target.className = 'fas fa-eye' + (isAudioVideoAllowed ? '' : '-slash'); + setColor(e.target, isAudioVideoAllowed ? 'white' : 'red'); + setColor(initAudioButton, isAudioAllowed ? 'white' : 'red'); + setColor(initVideoButton, isVideoAllowed ? 'white' : 'red'); + setColor(startAudioButton, isAudioAllowed ? 'white' : 'red'); + setColor(startVideoButton, isVideoAllowed ? 'white' : 'red'); +} + function checkMedia() { let qs = new URLSearchParams(window.location.search); let audio = qs.get('audio');