Merge pull request #757 from thecodingmachine/jitsiConfig
Merge Jitsi config
This commit is contained in:
commit
13078489c6
@ -3,7 +3,13 @@ import {mediaManager} from "./MediaManager";
|
|||||||
import {coWebsiteManager} from "./CoWebsiteManager";
|
import {coWebsiteManager} from "./CoWebsiteManager";
|
||||||
declare const window:any; // eslint-disable-line @typescript-eslint/no-explicit-any
|
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 {
|
return {
|
||||||
startWithAudioMuted: !mediaManager.constraintsMedia.audio,
|
startWithAudioMuted: !mediaManager.constraintsMedia.audio,
|
||||||
startWithVideoMuted: mediaManager.constraintsMedia.video === false,
|
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 = {
|
const defaultInterfaceConfig = {
|
||||||
SHOW_CHROME_EXTENSION_BANNER: false,
|
SHOW_CHROME_EXTENSION_BANNER: false,
|
||||||
MOBILE_APP_PROMO: false,
|
MOBILE_APP_PROMO: false,
|
||||||
@ -51,6 +69,7 @@ class JitsiFactory {
|
|||||||
private jitsiApi: any; // eslint-disable-line @typescript-eslint/no-explicit-any
|
private jitsiApi: any; // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||||
private audioCallback = this.onAudioChange.bind(this);
|
private audioCallback = this.onAudioChange.bind(this);
|
||||||
private videoCallback = this.onVideoChange.bind(this);
|
private videoCallback = this.onVideoChange.bind(this);
|
||||||
|
private previousConfigMeet? : jitsiConfigInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Slugifies the room name and prepends the room name with the instance
|
* 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 {
|
public start(roomName: string, playerName:string, jwt?: string, config?: object, interfaceConfig?: object): void {
|
||||||
|
//save previous config
|
||||||
|
this.previousConfigMeet = getDefaultConfig();
|
||||||
|
|
||||||
coWebsiteManager.insertCoWebsite((cowebsiteDiv => {
|
coWebsiteManager.insertCoWebsite((cowebsiteDiv => {
|
||||||
// Jitsi meet external API maintains some data in local storage
|
// Jitsi meet external API maintains some data in local storage
|
||||||
// which is sent via the appData URL parameter when joining a
|
// which is sent via the appData URL parameter when joining a
|
||||||
@ -76,7 +98,7 @@ class JitsiFactory {
|
|||||||
width: "100%",
|
width: "100%",
|
||||||
height: "100%",
|
height: "100%",
|
||||||
parentNode: cowebsiteDiv,
|
parentNode: cowebsiteDiv,
|
||||||
configOverwrite: {...config, ...getDefaultConfig()},
|
configOverwrite: mergeConfig(config),
|
||||||
interfaceConfigOverwrite: {...defaultInterfaceConfig, ...interfaceConfig}
|
interfaceConfigOverwrite: {...defaultInterfaceConfig, ...interfaceConfig}
|
||||||
};
|
};
|
||||||
if (!options.jwt) {
|
if (!options.jwt) {
|
||||||
@ -103,6 +125,19 @@ class JitsiFactory {
|
|||||||
this.jitsiApi.removeListener('audioMuteStatusChanged', this.audioCallback);
|
this.jitsiApi.removeListener('audioMuteStatusChanged', this.audioCallback);
|
||||||
this.jitsiApi.removeListener('videoMuteStatusChanged', this.videoCallback);
|
this.jitsiApi.removeListener('videoMuteStatusChanged', this.videoCallback);
|
||||||
this.jitsiApi?.dispose();
|
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 {
|
private onAudioChange({muted}: {muted: boolean}): void {
|
||||||
|
@ -40,6 +40,11 @@
|
|||||||
"name":"chillzone-2",
|
"name":"chillzone-2",
|
||||||
"opacity":1,
|
"opacity":1,
|
||||||
"properties":[
|
"properties":[
|
||||||
|
{
|
||||||
|
"name":"jitsiConfig",
|
||||||
|
"type":"string",
|
||||||
|
"value":"{ \"startWithAudioMuted\": true, \"startWithVideoMuted\": true } "
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name":"jitsiRoom",
|
"name":"jitsiRoom",
|
||||||
"type":"string",
|
"type":"string",
|
||||||
|
Loading…
Reference in New Issue
Block a user