import { Inject, Injectable } from '@angular/core'; import { BehaviorSubject, Observable } from 'rxjs'; import { OpenViduAngularConfig, ParticipantFactoryFunction } from '../../config/openvidu-angular.config'; // import { version } from '../../../../package.json'; @Injectable() export class OpenViduAngularConfigService { private configuration: OpenViduAngularConfig; minimal = >new BehaviorSubject(false); minimalObs: Observable; videoMuted = >new BehaviorSubject(false); videoMutedObs: Observable; audioMuted = >new BehaviorSubject(false); audioMutedObs: Observable; screenshareButton = >new BehaviorSubject(true); screenshareButtonObs: Observable; fullscreenButton = >new BehaviorSubject(true); fullscreenButtonObs: Observable; leaveButton = >new BehaviorSubject(true); leaveButtonObs: Observable; participantsPanelButton = >new BehaviorSubject(true); participantsPanelButtonObs: Observable; chatPanelButton = >new BehaviorSubject(true); chatPanelButtonObs: Observable; displaySessionName = >new BehaviorSubject(true); displaySessionNameObs: Observable; displayLogo = >new BehaviorSubject(true); displayLogoObs: Observable; displayParticipantName = >new BehaviorSubject(true); displayParticipantNameObs: Observable; displayAudioDetection = >new BehaviorSubject(true); displayAudioDetectionObs: Observable; settingsButton = >new BehaviorSubject(true); settingsButtonObs: Observable; constructor(@Inject('OPENVIDU_ANGULAR_CONFIG') config: OpenViduAngularConfig) { this.configuration = config; console.log(this.configuration); if(this.isProduction()) console.log('OpenVidu Angular Production Mode'); this.minimalObs = this.minimal.asObservable(); this.videoMutedObs = this.videoMuted.asObservable(); this.audioMutedObs = this.audioMuted.asObservable(); //Toolbar observables this.screenshareButtonObs = this.screenshareButton.asObservable(); this.fullscreenButtonObs = this.fullscreenButton.asObservable(); this.leaveButtonObs = this.leaveButton.asObservable(); this.participantsPanelButtonObs = this.participantsPanelButton.asObservable(); this.chatPanelButtonObs = this.chatPanelButton.asObservable(); this.displaySessionNameObs = this.displaySessionName.asObservable(); this.displayLogoObs = this.displayLogo.asObservable(); //Stream observables this.displayParticipantNameObs = this.displayParticipantName.asObservable(); this.displayAudioDetectionObs = this.displayAudioDetection.asObservable(); this.settingsButtonObs = this.settingsButton.asObservable(); } getConfig(): OpenViduAngularConfig { return this.configuration; } isProduction(): boolean { return this.configuration?.production; } isWebcomponent(): boolean { return this.configuration?.webcomponent; } hasParticipantFactory(): boolean { return typeof this.getConfig().participantFactory === "function"; } getParticipantFactory(): ParticipantFactoryFunction { return this.getConfig().participantFactory; } }