take both dominant speaker and jitsi participants count into consideration
This commit is contained in:
parent
8cccc0f095
commit
1df71e78e8
@ -71,7 +71,7 @@ import { biggestAvailableAreaStore } from "../../Stores/BiggestAvailableAreaStor
|
|||||||
import { layoutManagerActionStore } from "../../Stores/LayoutManagerStore";
|
import { layoutManagerActionStore } from "../../Stores/LayoutManagerStore";
|
||||||
import { playersStore } from "../../Stores/PlayersStore";
|
import { playersStore } from "../../Stores/PlayersStore";
|
||||||
import { emoteStore, emoteMenuStore } from "../../Stores/EmoteStore";
|
import { emoteStore, emoteMenuStore } from "../../Stores/EmoteStore";
|
||||||
import { userIsAdminStore, userIsJitsiDominantSpeakerStore } from "../../Stores/GameStore";
|
import { jitsiParticipantsCountStore, userIsAdminStore, userIsJitsiDominantSpeakerStore } from "../../Stores/GameStore";
|
||||||
import { contactPageStore } from "../../Stores/MenuStore";
|
import { contactPageStore } from "../../Stores/MenuStore";
|
||||||
import type { WasCameraUpdatedEvent } from "../../Api/Events/WasCameraUpdatedEvent";
|
import type { WasCameraUpdatedEvent } from "../../Api/Events/WasCameraUpdatedEvent";
|
||||||
import { audioManagerFileStore } from "../../Stores/AudioManagerStore";
|
import { audioManagerFileStore } from "../../Stores/AudioManagerStore";
|
||||||
@ -179,6 +179,7 @@ export class GameScene extends DirtyScene {
|
|||||||
private followUsersColorStoreUnsubscribe!: Unsubscriber;
|
private followUsersColorStoreUnsubscribe!: Unsubscriber;
|
||||||
private currentPlayerGroupIdStoreUnsubscribe!: Unsubscriber;
|
private currentPlayerGroupIdStoreUnsubscribe!: Unsubscriber;
|
||||||
private userIsJitsiDominantSpeakerStoreUnsubscriber!: Unsubscriber;
|
private userIsJitsiDominantSpeakerStoreUnsubscriber!: Unsubscriber;
|
||||||
|
private jitsiParticipantsCountStoreUnsubscriber!: Unsubscriber;
|
||||||
|
|
||||||
private biggestAvailableAreaStoreUnsubscribe!: () => void;
|
private biggestAvailableAreaStoreUnsubscribe!: () => void;
|
||||||
MapUrlFile: string;
|
MapUrlFile: string;
|
||||||
@ -222,6 +223,8 @@ export class GameScene extends DirtyScene {
|
|||||||
private firstCameraUpdateSent: boolean = false;
|
private firstCameraUpdateSent: boolean = false;
|
||||||
private showVoiceIndicatorChangeMessageSent: boolean = false;
|
private showVoiceIndicatorChangeMessageSent: boolean = false;
|
||||||
private currentPlayerGroupId?: number;
|
private currentPlayerGroupId?: number;
|
||||||
|
private jitsiDominantSpeaker: boolean = false;
|
||||||
|
private jitsiParticipantsCount: number = 0;
|
||||||
public readonly superLoad: SuperLoaderPlugin;
|
public readonly superLoad: SuperLoaderPlugin;
|
||||||
|
|
||||||
constructor(private room: Room, MapUrlFile: string, customKey?: string | undefined) {
|
constructor(private room: Room, MapUrlFile: string, customKey?: string | undefined) {
|
||||||
@ -667,10 +670,16 @@ export class GameScene extends DirtyScene {
|
|||||||
|
|
||||||
this.userIsJitsiDominantSpeakerStoreUnsubscriber = userIsJitsiDominantSpeakerStore.subscribe(
|
this.userIsJitsiDominantSpeakerStoreUnsubscriber = userIsJitsiDominantSpeakerStore.subscribe(
|
||||||
(dominantSpeaker) => {
|
(dominantSpeaker) => {
|
||||||
this.tryChangeShowVoiceIndicatorState(dominantSpeaker);
|
this.jitsiDominantSpeaker = dominantSpeaker;
|
||||||
|
this.tryChangeShowVoiceIndicatorState(this.jitsiDominantSpeaker && this.jitsiParticipantsCount > 1);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.jitsiParticipantsCountStoreUnsubscriber = jitsiParticipantsCountStore.subscribe((participantsCount) => {
|
||||||
|
this.jitsiParticipantsCount = participantsCount;
|
||||||
|
this.tryChangeShowVoiceIndicatorState(this.jitsiDominantSpeaker && this.jitsiParticipantsCount > 1);
|
||||||
|
});
|
||||||
|
|
||||||
this.emoteUnsubscribe = emoteStore.subscribe((emote) => {
|
this.emoteUnsubscribe = emoteStore.subscribe((emote) => {
|
||||||
if (emote) {
|
if (emote) {
|
||||||
this.CurrentPlayer?.playEmote(emote.url);
|
this.CurrentPlayer?.playEmote(emote.url);
|
||||||
|
@ -8,4 +8,6 @@ export const userIsAdminStore = writable(false);
|
|||||||
|
|
||||||
export const userIsJitsiDominantSpeakerStore = writable(false);
|
export const userIsJitsiDominantSpeakerStore = writable(false);
|
||||||
|
|
||||||
|
export const jitsiParticipantsCountStore = writable(0);
|
||||||
|
|
||||||
export const limitMapStore = writable(false);
|
export const limitMapStore = writable(false);
|
||||||
|
@ -4,7 +4,7 @@ import { requestedCameraState, requestedMicrophoneState } from "../Stores/MediaS
|
|||||||
import { get } from "svelte/store";
|
import { get } from "svelte/store";
|
||||||
import CancelablePromise from "cancelable-promise";
|
import CancelablePromise from "cancelable-promise";
|
||||||
import { gameManager } from "../Phaser/Game/GameManager";
|
import { gameManager } from "../Phaser/Game/GameManager";
|
||||||
import { userIsJitsiDominantSpeakerStore } from "../Stores/GameStore";
|
import { jitsiParticipantsCountStore, userIsJitsiDominantSpeakerStore } from "../Stores/GameStore";
|
||||||
|
|
||||||
interface jitsiConfigInterface {
|
interface jitsiConfigInterface {
|
||||||
startWithAudioMuted: boolean;
|
startWithAudioMuted: boolean;
|
||||||
@ -129,6 +129,7 @@ class JitsiFactory {
|
|||||||
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 dominantSpeakerChangedCallback = this.onDominantSpeakerChanged.bind(this);
|
private dominantSpeakerChangedCallback = this.onDominantSpeakerChanged.bind(this);
|
||||||
|
private participantsCountChangeCallback = this.onParticipantsCountChange.bind(this);
|
||||||
private jitsiScriptLoaded: boolean = false;
|
private jitsiScriptLoaded: boolean = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -203,11 +204,15 @@ class JitsiFactory {
|
|||||||
|
|
||||||
this.jitsiApi.addListener("videoConferenceJoined", () => {
|
this.jitsiApi.addListener("videoConferenceJoined", () => {
|
||||||
this.jitsiApi?.executeCommand("displayName", playerName);
|
this.jitsiApi?.executeCommand("displayName", playerName);
|
||||||
|
this.updateParticipantsCountStore();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.jitsiApi.addListener("audioMuteStatusChanged", this.audioCallback);
|
this.jitsiApi.addListener("audioMuteStatusChanged", this.audioCallback);
|
||||||
this.jitsiApi.addListener("videoMuteStatusChanged", this.videoCallback);
|
this.jitsiApi.addListener("videoMuteStatusChanged", this.videoCallback);
|
||||||
this.jitsiApi.addListener("dominantSpeakerChanged", this.dominantSpeakerChangedCallback);
|
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(() => {
|
cancel(() => {
|
||||||
@ -243,6 +248,7 @@ class JitsiFactory {
|
|||||||
|
|
||||||
public destroy() {
|
public destroy() {
|
||||||
userIsJitsiDominantSpeakerStore.set(false);
|
userIsJitsiDominantSpeakerStore.set(false);
|
||||||
|
jitsiParticipantsCountStore.set(0);
|
||||||
if (!this.jitsiApi) {
|
if (!this.jitsiApi) {
|
||||||
return;
|
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(
|
private getCurrentParticipantId(
|
||||||
participants: { displayName: string; participantId: string }[]
|
participants: { displayName: string; participantId: string }[]
|
||||||
): string | undefined {
|
): string | undefined {
|
||||||
|
Loading…
Reference in New Issue
Block a user