openvidu-components-angular: manage some incompatible VB situations

pull/721/head
pabloFuente 2022-05-05 18:07:33 +02:00
parent 7832f5a75f
commit 279da4eeaf
4 changed files with 26 additions and 17 deletions

View File

@ -19,7 +19,7 @@ export class BackgroundEffectsPanelComponent implements OnInit {
private backgrounds: BackgroundEffect[]; private backgrounds: BackgroundEffect[];
private backgroundSubs: Subscription; private backgroundSubs: Subscription;
constructor(private panelService: PanelService, private backgroundService: VirtualBackgroundService, private cd: ChangeDetectorRef) {} constructor(private panelService: PanelService, private backgroundService: VirtualBackgroundService, private cd: ChangeDetectorRef) { }
ngOnInit(): void { ngOnInit(): void {
this.subscribeToBackgroundSelected(); this.subscribeToBackgroundSelected();
@ -29,7 +29,7 @@ export class BackgroundEffectsPanelComponent implements OnInit {
} }
ngOnDestroy() { ngOnDestroy() {
if(this.backgroundSubs) this.backgroundSubs.unsubscribe(); if (this.backgroundSubs) this.backgroundSubs.unsubscribe();
} }
subscribeToBackgroundSelected() { subscribeToBackgroundSelected() {
this.backgroundSubs = this.backgroundService.backgroundSelectedObs.subscribe((id) => { this.backgroundSubs = this.backgroundService.backgroundSelectedObs.subscribe((id) => {
@ -43,13 +43,11 @@ export class BackgroundEffectsPanelComponent implements OnInit {
} }
async applyBackground(effect: BackgroundEffect) { async applyBackground(effect: BackgroundEffect) {
if (effect.type === EffectType.NONE) {
if(effect.type === EffectType.NONE){
await this.removeBackground(); await this.removeBackground();
} else { } else {
await this.backgroundService.applyBackground(effect); await this.backgroundService.applyBackground(effect);
} }
} }
async removeBackground() { async removeBackground() {

View File

@ -13,7 +13,7 @@
<ov-layout> <ov-layout>
<ng-template #stream let-stream> <ng-template #stream let-stream>
<button <button
*ngIf="!isMinimal && showBackgroundEffectsButton" *ngIf="!isMinimal && !isVideoMuted && showBackgroundEffectsButton"
mat-icon-button mat-icon-button
id="background-effects-btn" id="background-effects-btn"
(click)="toggleBackgroundEffects()" (click)="toggleBackgroundEffects()"

View File

@ -122,8 +122,16 @@ export class PreJoinComponent implements OnInit, OnDestroy {
// TODO: Remove this when replaceTrack issue is fixed // TODO: Remove this when replaceTrack issue is fixed
const pp: PublisherProperties = { videoSource, audioSource: this.microphoneSelected.device, mirror }; const pp: PublisherProperties = { videoSource, audioSource: this.microphoneSelected.device, mirror };
// Reapply Virtual Background to new Publisher if necessary
const backgroundSelected = this.backgroundService.backgroundSelected.getValue();
const backgroundWasApplied = !!backgroundSelected && backgroundSelected !== 'no_effect';
if (backgroundWasApplied) {
await this.backgroundService.removeBackground(); await this.backgroundService.removeBackground();
}
await this.openviduService.republishTrack(pp); await this.openviduService.republishTrack(pp);
if (backgroundWasApplied) {
await this.backgroundService.applyBackground(this.backgroundService.backgrounds.find(b => b.id === backgroundSelected));
}
this.deviceSrv.setCameraSelected(videoSource); this.deviceSrv.setCameraSelected(videoSource);
this.cameraSelected = this.deviceSrv.getCameraSelected(); this.cameraSelected = this.deviceSrv.getCameraSelected();
@ -152,6 +160,9 @@ export class PreJoinComponent implements OnInit, OnDestroy {
await this.openviduService.publishVideo(publish); await this.openviduService.publishVideo(publish);
this.isVideoMuted = !this.isVideoMuted; this.isVideoMuted = !this.isVideoMuted;
this.storageSrv.setVideoMuted(this.isVideoMuted); this.storageSrv.setVideoMuted(this.isVideoMuted);
if (this.isVideoMuted && this.panelService.isExternalPanelOpened()) {
this.panelService.togglePanel(PanelType.BACKGROUND_EFFECTS);
}
this.videoMuteChanging = false; this.videoMuteChanging = false;
} }

View File

@ -88,7 +88,7 @@ export class PanelService {
return this.isParticipantsOpened; return this.isParticipantsOpened;
} }
private isExternalPanelOpened(): boolean { isExternalPanelOpened(): boolean {
return this.isExternalOpened; return this.isExternalOpened;
} }
} }