openvidu-components: Fixed full screen status

pull/809/head
Carlos Santos 2023-05-30 13:08:17 +02:00
parent 6f691e8bb1
commit 0bd8a6f38d
1 changed files with 7 additions and 1 deletions

View File

@ -462,6 +462,7 @@ export class ToolbarComponent implements OnInit, OnDestroy, AfterViewInit {
this.menuTrigger?.menuOpened.subscribe(() => { this.menuTrigger?.menuOpened.subscribe(() => {
this.isSessionCreator = this.participantService.amIModerator(); this.isSessionCreator = this.participantService.amIModerator();
}); });
this.subscribeToFullscreenChanged();
} }
ngOnDestroy(): void { ngOnDestroy(): void {
@ -485,6 +486,7 @@ export class ToolbarComponent implements OnInit, OnDestroy, AfterViewInit {
if (this.screenSizeSub) this.screenSizeSub.unsubscribe(); if (this.screenSizeSub) this.screenSizeSub.unsubscribe();
if (this.settingsButtonSub) this.settingsButtonSub.unsubscribe(); if (this.settingsButtonSub) this.settingsButtonSub.unsubscribe();
if (this.captionsSubs) this.captionsSubs.unsubscribe(); if (this.captionsSubs) this.captionsSubs.unsubscribe();
document.removeEventListener('fullscreenchange', () => this.isFullscreenActive = false);
} }
/** /**
@ -638,7 +640,6 @@ export class ToolbarComponent implements OnInit, OnDestroy, AfterViewInit {
* @ignore * @ignore
*/ */
toggleFullscreen() { toggleFullscreen() {
this.isFullscreenActive = !this.isFullscreenActive;
this.documentService.toggleFullscreen('session-container'); this.documentService.toggleFullscreen('session-container');
this.onFullscreenButtonClicked.emit(); this.onFullscreenButtonClicked.emit();
} }
@ -659,6 +660,11 @@ export class ToolbarComponent implements OnInit, OnDestroy, AfterViewInit {
this.isConnectionLost = false; this.isConnectionLost = false;
}); });
} }
private subscribeToFullscreenChanged() {
document.addEventListener("fullscreenchange", (event) => this.isFullscreenActive = Boolean(document.fullscreenElement));
}
protected subscribeToMenuToggling() { protected subscribeToMenuToggling() {
this.panelTogglingSubscription = this.panelService.panelOpenedObs.subscribe((ev: PanelEvent) => { this.panelTogglingSubscription = this.panelService.panelOpenedObs.subscribe((ev: PanelEvent) => {
this.isChatOpened = ev.opened && ev.type === PanelType.CHAT; this.isChatOpened = ev.opened && ev.type === PanelType.CHAT;