Merge pull request #378 from thecodingmachine/jitsiQOL
disabling audio/video in jitsi carry over to wa
This commit is contained in:
commit
11541f9f55
@ -27,6 +27,9 @@ const interfaceConfig = {
|
||||
|
||||
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);
|
||||
|
||||
public start(roomName: string, playerName:string, jwt?: string): void {
|
||||
CoWebsiteManager.insertCoWebsite((cowebsiteDiv => {
|
||||
const domain = JITSI_URL;
|
||||
@ -48,13 +51,35 @@ class JitsiFactory {
|
||||
}
|
||||
this.jitsiApi = new window.JitsiMeetExternalAPI(domain, options);
|
||||
this.jitsiApi.executeCommand('displayName', playerName);
|
||||
|
||||
this.jitsiApi.addListener('audioMuteStatusChanged', this.audioCallback);
|
||||
this.jitsiApi.addListener('videoMuteStatusChanged', this.videoCallback);
|
||||
}));
|
||||
}
|
||||
|
||||
public stop(): void {
|
||||
this.jitsiApi.removeListener('audioMuteStatusChanged', this.audioCallback);
|
||||
this.jitsiApi.removeListener('videoMuteStatusChanged', this.videoCallback);
|
||||
this.jitsiApi?.dispose();
|
||||
CoWebsiteManager.closeCoWebsite();
|
||||
}
|
||||
|
||||
private onAudioChange({muted}: {muted: boolean}): void {
|
||||
if (muted && mediaManager.constraintsMedia.audio === true) {
|
||||
mediaManager.disableMicrophone();
|
||||
} else if(!muted && mediaManager.constraintsMedia.audio === false) {
|
||||
mediaManager.enableMicrophone();
|
||||
}
|
||||
}
|
||||
|
||||
private onVideoChange({muted}: {muted: boolean}): void {
|
||||
if (muted && mediaManager.constraintsMedia.video !== false) {
|
||||
mediaManager.disableCamera();
|
||||
} else if(!muted && mediaManager.constraintsMedia.video === false) {
|
||||
mediaManager.enableCamera();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const jitsiFactory = new JitsiFactory();
|
@ -135,7 +135,7 @@ export class MediaManager {
|
||||
gameOverlay.classList.remove('active');
|
||||
}
|
||||
|
||||
private enableCamera() {
|
||||
public enableCamera() {
|
||||
this.cinemaClose.style.display = "none";
|
||||
this.cinemaBtn.classList.remove("disabled");
|
||||
this.cinema.style.display = "block";
|
||||
@ -145,7 +145,7 @@ export class MediaManager {
|
||||
});
|
||||
}
|
||||
|
||||
private async disableCamera() {
|
||||
public async disableCamera() {
|
||||
this.cinemaClose.style.display = "block";
|
||||
this.cinema.style.display = "none";
|
||||
this.cinemaBtn.classList.add("disabled");
|
||||
@ -161,7 +161,7 @@ export class MediaManager {
|
||||
}
|
||||
}
|
||||
|
||||
private enableMicrophone() {
|
||||
public enableMicrophone() {
|
||||
this.microphoneClose.style.display = "none";
|
||||
this.microphone.style.display = "block";
|
||||
this.microphoneBtn.classList.remove("disabled");
|
||||
@ -172,7 +172,7 @@ export class MediaManager {
|
||||
});
|
||||
}
|
||||
|
||||
private async disableMicrophone() {
|
||||
public async disableMicrophone() {
|
||||
this.microphoneClose.style.display = "block";
|
||||
this.microphone.style.display = "none";
|
||||
this.microphoneBtn.classList.add("disabled");
|
||||
|
Loading…
Reference in New Issue
Block a user