take both dominant speaker and jitsi participants count into consideration
This commit is contained in:
committed by
David Négrier
parent
8cccc0f095
commit
1df71e78e8
@@ -4,7 +4,7 @@ import { requestedCameraState, requestedMicrophoneState } from "../Stores/MediaS
|
||||
import { get } from "svelte/store";
|
||||
import CancelablePromise from "cancelable-promise";
|
||||
import { gameManager } from "../Phaser/Game/GameManager";
|
||||
import { userIsJitsiDominantSpeakerStore } from "../Stores/GameStore";
|
||||
import { jitsiParticipantsCountStore, userIsJitsiDominantSpeakerStore } from "../Stores/GameStore";
|
||||
|
||||
interface jitsiConfigInterface {
|
||||
startWithAudioMuted: boolean;
|
||||
@@ -129,6 +129,7 @@ class JitsiFactory {
|
||||
private audioCallback = this.onAudioChange.bind(this);
|
||||
private videoCallback = this.onVideoChange.bind(this);
|
||||
private dominantSpeakerChangedCallback = this.onDominantSpeakerChanged.bind(this);
|
||||
private participantsCountChangeCallback = this.onParticipantsCountChange.bind(this);
|
||||
private jitsiScriptLoaded: boolean = false;
|
||||
|
||||
/**
|
||||
@@ -203,11 +204,15 @@ class JitsiFactory {
|
||||
|
||||
this.jitsiApi.addListener("videoConferenceJoined", () => {
|
||||
this.jitsiApi?.executeCommand("displayName", playerName);
|
||||
this.updateParticipantsCountStore();
|
||||
});
|
||||
|
||||
this.jitsiApi.addListener("audioMuteStatusChanged", this.audioCallback);
|
||||
this.jitsiApi.addListener("videoMuteStatusChanged", this.videoCallback);
|
||||
this.jitsiApi.addListener("dominantSpeakerChanged", this.dominantSpeakerChangedCallback);
|
||||
this.jitsiApi.addListener("participantJoined", this.participantsCountChangeCallback);
|
||||
this.jitsiApi.addListener("participantLeft", this.participantsCountChangeCallback);
|
||||
this.jitsiApi.addListener("participantKickedOut", this.participantsCountChangeCallback);
|
||||
});
|
||||
|
||||
cancel(() => {
|
||||
@@ -243,6 +248,7 @@ class JitsiFactory {
|
||||
|
||||
public destroy() {
|
||||
userIsJitsiDominantSpeakerStore.set(false);
|
||||
jitsiParticipantsCountStore.set(0);
|
||||
if (!this.jitsiApi) {
|
||||
return;
|
||||
}
|
||||
@@ -274,6 +280,15 @@ class JitsiFactory {
|
||||
);
|
||||
}
|
||||
|
||||
private onParticipantsCountChange(): void {
|
||||
this.updateParticipantsCountStore();
|
||||
}
|
||||
|
||||
private updateParticipantsCountStore(): void {
|
||||
//@ts-ignore
|
||||
jitsiParticipantsCountStore.set(this.jitsiApi?.getParticipantsInfo().length ?? 0);
|
||||
}
|
||||
|
||||
private getCurrentParticipantId(
|
||||
participants: { displayName: string; participantId: string }[]
|
||||
): string | undefined {
|
||||
|
||||
Reference in New Issue
Block a user