From 9dd3e8ff85b4485caa9319eea29e5ae87ac6145d Mon Sep 17 00:00:00 2001 From: Kharhamel Date: Wed, 6 Oct 2021 17:59:20 +0200 Subject: [PATCH] FIX: being in a silent zone new forces mediaConstraints to false --- front/src/Components/CameraControls.svelte | 3 +++ front/src/Stores/MediaStore.ts | 22 ++++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/front/src/Components/CameraControls.svelte b/front/src/Components/CameraControls.svelte index 6dc2726a..728c84e9 100644 --- a/front/src/Components/CameraControls.svelte +++ b/front/src/Components/CameraControls.svelte @@ -15,6 +15,7 @@ import {onDestroy} from "svelte"; function screenSharingClick(): void { + if (isSilent) return; if ($requestedScreenSharingState === true) { requestedScreenSharingState.disableScreenSharing(); } else { @@ -23,6 +24,7 @@ } function cameraClick(): void { + if (isSilent) return; if ($requestedCameraState === true) { requestedCameraState.disableWebcam(); } else { @@ -31,6 +33,7 @@ } function microphoneClick(): void { + if (isSilent) return; if ($requestedMicrophoneState === true) { requestedMicrophoneState.disableMicrophone(); } else { diff --git a/front/src/Stores/MediaStore.ts b/front/src/Stores/MediaStore.ts index c5bfdc83..8a8e39e2 100644 --- a/front/src/Stores/MediaStore.ts +++ b/front/src/Stores/MediaStore.ts @@ -177,6 +177,11 @@ function createVideoConstraintStore() { }; } +/** + * A store containing if user is silent, so if he is in silent zone. This permit to show et hide camera of user + */ +export const isSilentStore = writable(false); + export const videoConstraintStore = createVideoConstraintStore(); /** @@ -234,6 +239,7 @@ export const mediaStreamConstraintsStore = derived( audioConstraintStore, privacyShutdownStore, cameraEnergySavingStore, + isSilentStore, ], ( [ @@ -245,6 +251,7 @@ export const mediaStreamConstraintsStore = derived( $audioConstraintStore, $privacyShutdownStore, $cameraEnergySavingStore, + $isSilentStore, ], set ) => { @@ -294,6 +301,11 @@ export const mediaStreamConstraintsStore = derived( //currentAudioConstraint = false; } + if ($isSilentStore === true) { + currentVideoConstraint = false; + currentAudioConstraint = false; + } + // Let's make the changes only if the new value is different from the old one. if ( previousComputedVideoConstraint != currentVideoConstraint || @@ -607,13 +619,3 @@ localStreamStore.subscribe((streamResult) => { } } }); - -/** - * A store containing the real active media is mobile - */ -export const obtainedMediaConstraintIsMobileStore = writable(false); - -/** - * A store containing if user is silent, so if he is in silent zone. This permit to show et hide camera of user - */ -export const isSilentStore = writable(false);