From 2bf212ccfefa9f36706480fbbcbec9efd7d58a73 Mon Sep 17 00:00:00 2001 From: Carlos Santos <4a.santos@gmail.com> Date: Mon, 10 Mar 2025 10:11:38 +0100 Subject: [PATCH] ov-components: add camera and microphone button visibility controls in toolbar and settings panel --- .../settings-panel.component.html | 6 +- .../settings-panel.component.ts | 13 +- .../pre-join/pre-join.component.html | 4 +- .../components/pre-join/pre-join.component.ts | 14 +- .../components/toolbar/toolbar.component.html | 2 + .../components/toolbar/toolbar.component.ts | 20 +++ .../directives/api/api.directive.module.ts | 8 +- .../lib/directives/api/toolbar.directive.ts | 131 ++++++++++++++++++ .../config/directive-config.service.ts | 27 ++++ .../src/app/openvidu-call/call.component.html | 2 + 10 files changed, 217 insertions(+), 10 deletions(-) diff --git a/openvidu-components-angular/projects/openvidu-components-angular/src/lib/components/panel/settings-panel/settings-panel.component.html b/openvidu-components-angular/projects/openvidu-components-angular/src/lib/components/panel/settings-panel/settings-panel.component.html index f4673e74..2d592122 100644 --- a/openvidu-components-angular/projects/openvidu-components-angular/src/lib/components/panel/settings-panel/settings-panel.component.html +++ b/openvidu-components-angular/projects/openvidu-components-angular/src/lib/components/panel/settings-panel/settings-panel.component.html @@ -25,6 +25,7 @@
{{ 'PANEL.SETTINGS.GENERAL' | translate }}
{{ 'PANEL.SETTINGS.VIDEO' | translate }} diff --git a/openvidu-components-angular/projects/openvidu-components-angular/src/lib/components/panel/settings-panel/settings-panel.component.ts b/openvidu-components-angular/projects/openvidu-components-angular/src/lib/components/panel/settings-panel/settings-panel.component.ts index 88031c05..85c960f7 100644 --- a/openvidu-components-angular/projects/openvidu-components-angular/src/lib/components/panel/settings-panel/settings-panel.component.ts +++ b/openvidu-components-angular/projects/openvidu-components-angular/src/lib/components/panel/settings-panel/settings-panel.component.ts @@ -23,9 +23,13 @@ export class SettingsPanelComponent implements OnInit { @Output() onLangChanged = new EventEmitter(); settingsOptions: typeof PanelSettingsOptions = PanelSettingsOptions; selectedOption: PanelSettingsOptions = PanelSettingsOptions.GENERAL; + showCameraButton: boolean = true; + showMicrophoneButton: boolean = true; showCaptions: boolean = true; panelSubscription: Subscription; isMobile: boolean = false; + private cameraButtonSub: Subscription; + private microphoneButtonSub: Subscription; private captionsSubs: Subscription; constructor( private panelService: PanelService, @@ -39,6 +43,9 @@ export class SettingsPanelComponent implements OnInit { } ngOnDestroy() { + if (this.panelSubscription) this.panelSubscription.unsubscribe(); + if (this.cameraButtonSub) this.cameraButtonSub.unsubscribe(); + if (this.microphoneButtonSub) this.microphoneButtonSub.unsubscribe(); if (this.captionsSubs) this.captionsSubs.unsubscribe(); } @@ -50,9 +57,9 @@ export class SettingsPanelComponent implements OnInit { } private subscribeToDirectives() { - this.captionsSubs = this.libService.captionsButton$.subscribe((value: boolean) => { - this.showCaptions = value; - }); + this.cameraButtonSub = this.libService.cameraButton$.subscribe((value: boolean) => (this.showCameraButton = value)); + this.microphoneButtonSub = this.libService.microphoneButton$.subscribe((value: boolean) => (this.showMicrophoneButton = value)); + this.captionsSubs = this.libService.captionsButton$.subscribe((value: boolean) => (this.showCaptions = value)); } private subscribeToPanelToggling() { diff --git a/openvidu-components-angular/projects/openvidu-components-angular/src/lib/components/pre-join/pre-join.component.html b/openvidu-components-angular/projects/openvidu-components-angular/src/lib/components/pre-join/pre-join.component.html index fe4e0fa5..e9d51825 100644 --- a/openvidu-components-angular/projects/openvidu-components-angular/src/lib/components/pre-join/pre-join.component.html +++ b/openvidu-components-angular/projects/openvidu-components-angular/src/lib/components/pre-join/pre-join.component.html @@ -24,7 +24,7 @@
-
+
-
+
{ + this.showCameraButton = value; + }); + this.microphoneButtonSub = this.libService.microphoneButton$.subscribe((value: boolean) => { + this.showMicrophoneButton = value; + }); this.displayLogoSub = this.libService.displayLogo$.subscribe((value: boolean) => { this.showLogo = value; // this.cd.markForCheck(); diff --git a/openvidu-components-angular/projects/openvidu-components-angular/src/lib/components/toolbar/toolbar.component.html b/openvidu-components-angular/projects/openvidu-components-angular/src/lib/components/toolbar/toolbar.component.html index 6d639552..60406bcd 100644 --- a/openvidu-components-angular/projects/openvidu-components-angular/src/lib/components/toolbar/toolbar.component.html +++ b/openvidu-components-angular/projects/openvidu-components-angular/src/lib/components/toolbar/toolbar.component.html @@ -32,6 +32,7 @@