diff --git a/front/src/WebRtc/JitsiFactory.ts b/front/src/WebRtc/JitsiFactory.ts index 41a5c388..c06da18a 100644 --- a/front/src/WebRtc/JitsiFactory.ts +++ b/front/src/WebRtc/JitsiFactory.ts @@ -3,7 +3,13 @@ import {mediaManager} from "./MediaManager"; import {coWebsiteManager} from "./CoWebsiteManager"; 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 +17,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, @@ -51,6 +69,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 @@ -60,6 +79,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 @@ -76,7 +98,7 @@ class JitsiFactory { width: "100%", height: "100%", parentNode: cowebsiteDiv, - configOverwrite: {...config, ...getDefaultConfig()}, + configOverwrite: mergeConfig(config), interfaceConfigOverwrite: {...defaultInterfaceConfig, ...interfaceConfig} }; if (!options.jwt) { @@ -103,6 +125,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 24b28d6c..77f0f2d9 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",