Merge pull request #757 from thecodingmachine/jitsiConfig

Merge Jitsi config
This commit is contained in:
grégoire parant 2021-02-17 20:34:31 +01:00 committed by GitHub
commit 13078489c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 2 deletions

View File

@ -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 {

View File

@ -40,6 +40,11 @@
"name":"chillzone-2",
"opacity":1,
"properties":[
{
"name":"jitsiConfig",
"type":"string",
"value":"{ \"startWithAudioMuted\": true, \"startWithVideoMuted\": true } "
},
{
"name":"jitsiRoom",
"type":"string",