From e8b1b286a3ddb80dfd5620f368dcf1583b093f43 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Wed, 17 Feb 2021 18:49:55 +0100 Subject: [PATCH 1/3] Merge Jitsi config --- front/src/WebRtc/JitsiFactory.ts | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/front/src/WebRtc/JitsiFactory.ts b/front/src/WebRtc/JitsiFactory.ts index 41a5c388..860c2919 100644 --- a/front/src/WebRtc/JitsiFactory.ts +++ b/front/src/WebRtc/JitsiFactory.ts @@ -1,9 +1,16 @@ import {JITSI_URL} from "../Enum/EnvironmentVariable"; import {mediaManager} from "./MediaManager"; import {coWebsiteManager} from "./CoWebsiteManager"; +import {AddPlayerInterface} from "../Phaser/Game/AddPlayerInterface"; declare const window:any; // eslint-disable-line @typescript-eslint/no-explicit-any -const getDefaultConfig = () => { +interface jitsiConfigInterface { + startWithAudioMuted: boolean + startWithVideoMuted: boolean + prejoinPageEnabled: boolean +} + +const getDefaultConfig = () : jitsiConfigInterface => { return { startWithAudioMuted: !mediaManager.constraintsMedia.audio, startWithVideoMuted: mediaManager.constraintsMedia.video === false, @@ -11,6 +18,18 @@ const getDefaultConfig = () => { } } +const mergeConfig = (config?: object) => { + const currentDefaultConfig = getDefaultConfig(); + if(!config){ + return currentDefaultConfig; + } + return { + startWithAudioMuted: (config as jitsiConfigInterface).startWithAudioMuted ? true : currentDefaultConfig.startWithAudioMuted, + startWithVideoMuted: (config as jitsiConfigInterface).startWithVideoMuted ? true : currentDefaultConfig.startWithVideoMuted, + prejoinPageEnabled: (config as jitsiConfigInterface).prejoinPageEnabled ? true : currentDefaultConfig.prejoinPageEnabled + } +} + const defaultInterfaceConfig = { SHOW_CHROME_EXTENSION_BANNER: false, MOBILE_APP_PROMO: false, @@ -76,7 +95,7 @@ class JitsiFactory { width: "100%", height: "100%", parentNode: cowebsiteDiv, - configOverwrite: {...config, ...getDefaultConfig()}, + configOverwrite: mergeConfig(config), interfaceConfigOverwrite: {...defaultInterfaceConfig, ...interfaceConfig} }; if (!options.jwt) { From baae1e81251a645ff952fe89c67c3b4a6aca5bbb Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Wed, 17 Feb 2021 19:21:37 +0100 Subject: [PATCH 2/3] Update to restore previous config --- front/src/WebRtc/JitsiFactory.ts | 17 +++++++++++++++++ maps/Floor0/floor0.json | 9 +++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/front/src/WebRtc/JitsiFactory.ts b/front/src/WebRtc/JitsiFactory.ts index 860c2919..35bc2c22 100644 --- a/front/src/WebRtc/JitsiFactory.ts +++ b/front/src/WebRtc/JitsiFactory.ts @@ -70,6 +70,7 @@ class JitsiFactory { private jitsiApi: any; // eslint-disable-line @typescript-eslint/no-explicit-any private audioCallback = this.onAudioChange.bind(this); private videoCallback = this.onVideoChange.bind(this); + private previousConfigMeet? : jitsiConfigInterface; /** * Slugifies the room name and prepends the room name with the instance @@ -79,6 +80,9 @@ class JitsiFactory { } public start(roomName: string, playerName:string, jwt?: string, config?: object, interfaceConfig?: object): void { + //save previous config + this.previousConfigMeet = getDefaultConfig(); + coWebsiteManager.insertCoWebsite((cowebsiteDiv => { // Jitsi meet external API maintains some data in local storage // which is sent via the appData URL parameter when joining a @@ -122,6 +126,19 @@ class JitsiFactory { this.jitsiApi.removeListener('audioMuteStatusChanged', this.audioCallback); this.jitsiApi.removeListener('videoMuteStatusChanged', this.videoCallback); this.jitsiApi?.dispose(); + + //restore previous config + if(this.previousConfigMeet?.startWithAudioMuted){ + mediaManager.disableMicrophone(); + }else{ + mediaManager.enableMicrophone(); + } + + if(this.previousConfigMeet?.startWithVideoMuted){ + mediaManager.disableCamera(); + }else{ + mediaManager.enableCamera(); + } } private onAudioChange({muted}: {muted: boolean}): void { diff --git a/maps/Floor0/floor0.json b/maps/Floor0/floor0.json index 6a88f78d..f5f2ee12 100644 --- a/maps/Floor0/floor0.json +++ b/maps/Floor0/floor0.json @@ -40,6 +40,11 @@ "name":"chillzone-2", "opacity":1, "properties":[ + { + "name":"jitsiConfig", + "type":"string", + "value":"{ \"startWithAudioMuted\": true, \"startWithVideoMuted\": true } " + }, { "name":"jitsiRoom", "type":"string", @@ -433,7 +438,7 @@ "nextobjectid":2, "orientation":"orthogonal", "renderorder":"right-down", - "tiledversion":"1.3.3", + "tiledversion":"1.4.3", "tileheight":32, "tilesets":[ { @@ -2379,6 +2384,6 @@ }], "tilewidth":32, "type":"map", - "version":1.2, + "version":1.4, "width":46 } \ No newline at end of file From 5ddf909fe62c26aacdf4e67733c4bd38dcbc82db Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Wed, 17 Feb 2021 20:26:33 +0100 Subject: [PATCH 3/3] Remove unless export constante --- front/src/WebRtc/JitsiFactory.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/front/src/WebRtc/JitsiFactory.ts b/front/src/WebRtc/JitsiFactory.ts index 35bc2c22..c06da18a 100644 --- a/front/src/WebRtc/JitsiFactory.ts +++ b/front/src/WebRtc/JitsiFactory.ts @@ -1,7 +1,6 @@ import {JITSI_URL} from "../Enum/EnvironmentVariable"; import {mediaManager} from "./MediaManager"; import {coWebsiteManager} from "./CoWebsiteManager"; -import {AddPlayerInterface} from "../Phaser/Game/AddPlayerInterface"; declare const window:any; // eslint-disable-line @typescript-eslint/no-explicit-any interface jitsiConfigInterface {