2022-02-24 10:16:23 +01:00
|
|
|
import {
|
2022-02-24 10:20:32 +01:00
|
|
|
ChangeDetectionStrategy,
|
|
|
|
ChangeDetectorRef,
|
2022-02-24 10:16:23 +01:00
|
|
|
Component,
|
|
|
|
ContentChild,
|
|
|
|
EventEmitter,
|
|
|
|
HostListener,
|
|
|
|
OnDestroy,
|
|
|
|
OnInit,
|
|
|
|
Output,
|
|
|
|
TemplateRef
|
|
|
|
} from '@angular/core';
|
2022-01-19 17:24:11 +01:00
|
|
|
import { skip, Subscription } from 'rxjs';
|
|
|
|
import { TokenService } from '../../services/token/token.service';
|
|
|
|
import { ChatService } from '../../services/chat/chat.service';
|
|
|
|
import { SidenavMenuService } from '../../services/sidenav-menu/sidenav-menu.service';
|
|
|
|
import { DocumentService } from '../../services/document/document.service';
|
|
|
|
|
2022-02-15 15:52:59 +01:00
|
|
|
import { OpenViduService } from '../../services/openvidu/openvidu.service';
|
2022-01-19 17:24:11 +01:00
|
|
|
import { LoggerService } from '../../services/logger/logger.service';
|
|
|
|
import { ILogger } from '../../models/logger.model';
|
|
|
|
import { ScreenType } from '../../models/video-type.model';
|
|
|
|
import { PublisherProperties, Session } from 'openvidu-browser';
|
|
|
|
import { ActionService } from '../../services/action/action.service';
|
|
|
|
import { DeviceService } from '../../services/device/device.service';
|
|
|
|
import { ChatMessage } from '../../models/chat.model';
|
|
|
|
import { ParticipantService } from '../../services/participant/participant.service';
|
|
|
|
import { MenuType } from '../../models/menu.model';
|
2022-03-07 15:50:27 +01:00
|
|
|
import { OpenViduAngularConfigService } from '../../services/config/openvidu-angular.config.service';
|
2022-03-10 11:42:48 +01:00
|
|
|
import { ToolbarAdditionalButtonsDirective } from '../../directives/template/openvidu-angular.directive';
|
2022-01-19 17:24:11 +01:00
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* The **ToolbarComponent** is hosted inside of the {@link VideoconferenceComponent}.
|
|
|
|
* It is in charge of displaying the participants controlls for handling the media, panels and more videoconference features.
|
|
|
|
*
|
|
|
|
* <div class="custom-table-container">
|
|
|
|
* <div>
|
|
|
|
* <h3>API Directives</h3>
|
|
|
|
*
|
|
|
|
* This component allows us to show or hide certain HTML elements with the following {@link https://angular.io/guide/attribute-directives Angular attribute directives}
|
|
|
|
* with the aim of fully customizing the ToolbarComponent.
|
|
|
|
*
|
|
|
|
* | **Name** | **Type** | **Reference** |
|
|
|
|
* | :----------------------------: | :-------: | :---------------------------------------------: |
|
|
|
|
* | **screenshareButton** | `boolean` | {@link ToolbarScreenshareButtonDirective} |
|
|
|
|
* | **fullscreenButton** | `boolean` | {@link ToolbarFullscreenButtonDirective} |
|
|
|
|
* | **leaveButton** | `boolean` | {@link ToolbarLeaveButtonDirective} |
|
|
|
|
* | **chatPanelButton** | `boolean` | {@link ToolbarChatPanelButtonDirective} |
|
|
|
|
* | **participantsPanelButton** | `boolean` | {@link ToolbarParticipantsPanelButtonDirective} |
|
|
|
|
* | **displayLogo** | `boolean` | {@link ToolbarDisplayLogoDirective} |
|
|
|
|
* | **displaySessionName** | `boolean` | {@link ToolbarDisplaySessionNameDirective} |
|
|
|
|
*
|
|
|
|
* <p class="component-link-text">
|
|
|
|
* <span class="italic">See all {@link ApiDirectiveModule API Directives}</span>
|
|
|
|
* </p>
|
|
|
|
*
|
|
|
|
* </div>
|
|
|
|
* <div>
|
|
|
|
*
|
|
|
|
* <h3>OpenVidu Angular Directives</h3>
|
|
|
|
*
|
|
|
|
* The ToolbarComponent can be replaced with a custom component. It provides us the following {@link https://angular.io/guide/structural-directives Angular structural directives}
|
|
|
|
* for doing this.
|
|
|
|
*
|
|
|
|
* | **Directive** | **Reference** |
|
|
|
|
* |:----------------------------------:|:---------------------------------------------:|
|
|
|
|
* | ***ovToolbar** | {@link ToolbarDirective} |
|
|
|
|
*
|
|
|
|
* </br>
|
|
|
|
*
|
|
|
|
* It is also providing us a way to **add additional buttons** to the default toolbar.
|
|
|
|
* It will recognise the following directive in a child element.
|
|
|
|
*
|
|
|
|
* | **Directive** | **Reference** |
|
|
|
|
* |:----------------------------------:|:---------------------------------------------:|
|
|
|
|
* | ***ovToolbarAdditionalButtons** | {@link ToolbarAdditionalButtonsDirective} |
|
|
|
|
*
|
|
|
|
* <p class="component-link-text">
|
|
|
|
* <span class="italic">See all {@link OpenViduAngularDirectiveModule OpenVidu Angular Directives}</span>
|
|
|
|
* </p>
|
|
|
|
* </div>
|
|
|
|
* </div>
|
|
|
|
*/
|
|
|
|
|
2022-01-19 17:24:11 +01:00
|
|
|
@Component({
|
|
|
|
selector: 'ov-toolbar',
|
|
|
|
templateUrl: './toolbar.component.html',
|
2022-02-24 10:20:32 +01:00
|
|
|
styleUrls: ['./toolbar.component.css'],
|
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush
|
2022-01-19 17:24:11 +01:00
|
|
|
})
|
|
|
|
export class ToolbarComponent implements OnInit, OnDestroy {
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-03-10 11:42:48 +01:00
|
|
|
@ContentChild('toolbarAdditionalButtons', { read: TemplateRef }) toolbarAdditionalButtonsTemplate: TemplateRef<any>;
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-03-10 11:42:48 +01:00
|
|
|
@ContentChild(ToolbarAdditionalButtonsDirective)
|
|
|
|
set externalAdditionalButtons(externalAdditionalButtons: ToolbarAdditionalButtonsDirective) {
|
|
|
|
// This directive will has value only when ADDITIONAL BUTTONS component tagget with '*ovToolbarAdditionalButtons' directive
|
|
|
|
// is inside of the TOOLBAR component tagged with '*ovToolbar' directive
|
|
|
|
if (externalAdditionalButtons) {
|
|
|
|
this.toolbarAdditionalButtonsTemplate = externalAdditionalButtons.template;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-09 15:31:21 +01:00
|
|
|
@Output() onLeaveButtonClicked = new EventEmitter<any>();
|
|
|
|
@Output() onCameraButtonClicked = new EventEmitter<any>();
|
|
|
|
@Output() onMicrophoneButtonClicked = new EventEmitter<any>();
|
|
|
|
@Output() onFullscreenButtonClicked = new EventEmitter<any>();
|
|
|
|
@Output() onScreenshareButtonClicked = new EventEmitter<any>();
|
|
|
|
@Output() onParticipantsPanelButtonClicked = new EventEmitter<any>();
|
|
|
|
@Output() onChatPanelButtonClicked = new EventEmitter<any>();
|
2022-01-19 17:24:11 +01:00
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-01-19 17:24:11 +01:00
|
|
|
session: Session;
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-01-19 17:24:11 +01:00
|
|
|
unreadMessages: number = 0;
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-01-19 17:24:11 +01:00
|
|
|
messageList: ChatMessage[] = [];
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-02-24 10:16:23 +01:00
|
|
|
isScreenShareActive: boolean;
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-02-24 10:16:23 +01:00
|
|
|
isWebcamVideoActive: boolean;
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-02-24 10:16:23 +01:00
|
|
|
isWebcamAudioActive: boolean;
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-01-19 17:24:11 +01:00
|
|
|
isConnectionLost: boolean;
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-01-19 17:24:11 +01:00
|
|
|
hasVideoDevices: boolean;
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-01-19 17:24:11 +01:00
|
|
|
hasAudioDevices: boolean;
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-02-24 10:16:23 +01:00
|
|
|
isFullscreenActive: boolean = false;
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-01-19 17:24:11 +01:00
|
|
|
isChatOpened: boolean = false;
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-01-19 17:24:11 +01:00
|
|
|
isParticipantsOpened: boolean = false;
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-03-07 15:50:27 +01:00
|
|
|
isMinimal: boolean = false;
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-03-07 15:50:27 +01:00
|
|
|
showScreenshareButton = true;
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-03-07 15:50:27 +01:00
|
|
|
showFullscreenButton: boolean = true;
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-03-07 15:50:27 +01:00
|
|
|
showLeaveButton: boolean = true;
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-03-07 15:50:27 +01:00
|
|
|
showParticipantsPanelButton: boolean = true;
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-03-07 15:50:27 +01:00
|
|
|
showChatPanelButton: boolean = true;
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-03-07 15:50:27 +01:00
|
|
|
showLogo: boolean = true;
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-03-07 15:50:27 +01:00
|
|
|
showSessionName: boolean = true;
|
2022-01-19 17:24:11 +01:00
|
|
|
|
2022-03-07 15:50:27 +01:00
|
|
|
private log: ILogger;
|
|
|
|
private minimalSub: Subscription;
|
|
|
|
private menuTogglingSubscription: Subscription;
|
|
|
|
private chatMessagesSubscription: Subscription;
|
|
|
|
private localParticipantSubscription: Subscription;
|
|
|
|
private screenshareButtonSub: Subscription;
|
|
|
|
private fullscreenButtonSub: Subscription;
|
|
|
|
private leaveButtonSub: Subscription;
|
|
|
|
private participantsPanelButtonSub: Subscription;
|
|
|
|
private chatPanelButtonSub: Subscription;
|
|
|
|
private displayLogoSub: Subscription;
|
|
|
|
private displaySessionNameSub: Subscription;
|
|
|
|
private currentWindowHeight = window.innerHeight;
|
2022-01-19 17:24:11 +01:00
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
|
|
|
constructor(
|
|
|
|
protected documentService: DocumentService,
|
|
|
|
protected chatService: ChatService,
|
|
|
|
protected menuService: SidenavMenuService,
|
|
|
|
protected tokenService: TokenService,
|
|
|
|
protected participantService: ParticipantService,
|
|
|
|
protected openviduService: OpenViduService,
|
|
|
|
protected oVDevicesService: DeviceService,
|
|
|
|
protected actionService: ActionService,
|
|
|
|
protected loggerSrv: LoggerService,
|
|
|
|
private cd: ChangeDetectorRef,
|
|
|
|
private libService: OpenViduAngularConfigService
|
|
|
|
) {
|
|
|
|
this.log = this.loggerSrv.get('ToolbarComponent');
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-01-19 17:24:11 +01:00
|
|
|
@HostListener('window:resize', ['$event'])
|
|
|
|
sizeChange(event) {
|
2022-03-07 15:50:27 +01:00
|
|
|
if (this.currentWindowHeight >= window.innerHeight) {
|
2022-02-24 10:16:23 +01:00
|
|
|
// The user has exit the fullscreen mode
|
|
|
|
this.isFullscreenActive = false;
|
|
|
|
this.currentWindowHeight = window.innerHeight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-02-24 10:16:23 +01:00
|
|
|
@HostListener('document:keydown', ['$event'])
|
|
|
|
keyDown(event: KeyboardEvent) {
|
2022-03-07 15:50:27 +01:00
|
|
|
if (event.key === 'F11') {
|
2022-02-24 10:16:23 +01:00
|
|
|
event.preventDefault();
|
|
|
|
this.toggleFullscreen();
|
|
|
|
this.currentWindowHeight = window.innerHeight;
|
|
|
|
return false;
|
|
|
|
}
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
async ngOnInit() {
|
2022-03-07 15:50:27 +01:00
|
|
|
this.subscribeToToolbarDirectives();
|
|
|
|
|
2022-01-19 17:24:11 +01:00
|
|
|
await this.oVDevicesService.initializeDevices();
|
|
|
|
this.hasVideoDevices = this.oVDevicesService.hasVideoDeviceAvailable();
|
|
|
|
this.hasAudioDevices = this.oVDevicesService.hasAudioDeviceAvailable();
|
2022-02-15 15:52:59 +01:00
|
|
|
this.session = this.openviduService.getWebcamSession();
|
2022-01-19 17:24:11 +01:00
|
|
|
|
|
|
|
this.subscribeToUserMediaProperties();
|
|
|
|
this.subscribeToReconnection();
|
2022-02-14 14:12:58 +01:00
|
|
|
this.subscribeToMenuToggling();
|
|
|
|
this.subscribeToChatMessages();
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
|
2022-03-07 15:50:27 +01:00
|
|
|
ngOnDestroy(): void {
|
|
|
|
if (this.menuTogglingSubscription) this.menuTogglingSubscription.unsubscribe();
|
|
|
|
if (this.chatMessagesSubscription) this.chatMessagesSubscription.unsubscribe();
|
|
|
|
if (this.localParticipantSubscription) this.localParticipantSubscription.unsubscribe();
|
|
|
|
if (this.screenshareButtonSub) this.screenshareButtonSub.unsubscribe();
|
|
|
|
if (this.fullscreenButtonSub) this.fullscreenButtonSub.unsubscribe();
|
|
|
|
if (this.leaveButtonSub) this.leaveButtonSub.unsubscribe();
|
|
|
|
if (this.participantsPanelButtonSub) this.participantsPanelButtonSub.unsubscribe();
|
|
|
|
if (this.chatPanelButtonSub) this.chatPanelButtonSub.unsubscribe();
|
|
|
|
if (this.displayLogoSub) this.displayLogoSub.unsubscribe();
|
|
|
|
if (this.displaySessionNameSub) this.displaySessionNameSub.unsubscribe();
|
2022-03-23 13:48:17 +01:00
|
|
|
if (this.minimalSub) this.minimalSub.unsubscribe();
|
2022-03-07 15:50:27 +01:00
|
|
|
}
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-01-19 17:24:11 +01:00
|
|
|
toggleMicrophone() {
|
2022-03-09 15:31:21 +01:00
|
|
|
this.onMicrophoneButtonClicked.emit();
|
2022-01-19 17:24:11 +01:00
|
|
|
|
2022-02-25 11:19:21 +01:00
|
|
|
if (this.participantService.isMyCameraActive()) {
|
2022-02-15 15:52:59 +01:00
|
|
|
this.openviduService.publishAudio(
|
2022-01-19 17:24:11 +01:00
|
|
|
this.participantService.getMyCameraPublisher(),
|
|
|
|
!this.participantService.hasCameraAudioActive()
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
2022-02-15 15:52:59 +01:00
|
|
|
this.openviduService.publishAudio(this.participantService.getMyScreenPublisher(), !this.participantService.hasScreenAudioActive());
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-01-19 17:24:11 +01:00
|
|
|
async toggleCamera() {
|
2022-03-09 15:31:21 +01:00
|
|
|
this.onCameraButtonClicked.emit();
|
2022-01-19 17:24:11 +01:00
|
|
|
|
|
|
|
try {
|
|
|
|
const publishVideo = !this.participantService.hasCameraVideoActive();
|
|
|
|
const publishAudio = this.participantService.hasCameraAudioActive();
|
|
|
|
// Disabling webcam
|
2022-02-25 11:19:21 +01:00
|
|
|
if (this.participantService.haveICameraAndScreenActive()) {
|
2022-02-15 15:52:59 +01:00
|
|
|
this.openviduService.publishVideo(this.participantService.getMyCameraPublisher(), publishVideo);
|
2022-03-23 13:45:30 +01:00
|
|
|
this.participantService.disableWebcamStream();
|
2022-02-15 15:52:59 +01:00
|
|
|
this.openviduService.unpublish(this.participantService.getMyCameraPublisher());
|
|
|
|
this.openviduService.publishAudio(this.participantService.getMyScreenPublisher(), publishAudio);
|
2022-01-19 17:24:11 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Enabling webcam
|
2022-02-25 11:19:21 +01:00
|
|
|
if (this.participantService.isOnlyMyScreenActive()) {
|
2022-01-19 17:24:11 +01:00
|
|
|
const hasAudio = this.participantService.hasScreenAudioActive();
|
|
|
|
|
2022-02-15 15:52:59 +01:00
|
|
|
if (!this.openviduService.isWebcamSessionConnected()) {
|
|
|
|
await this.openviduService.connectSession(this.openviduService.getWebcamSession(), this.tokenService.getWebcamToken());
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
2022-02-15 15:52:59 +01:00
|
|
|
await this.openviduService.publish(this.participantService.getMyCameraPublisher());
|
|
|
|
this.openviduService.publishAudio(this.participantService.getMyScreenPublisher(), false);
|
|
|
|
this.openviduService.publishAudio(this.participantService.getMyCameraPublisher(), hasAudio);
|
2022-03-23 13:45:30 +01:00
|
|
|
this.participantService.enableWebcamStream();
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
// Muting/unmuting webcam
|
2022-02-15 15:52:59 +01:00
|
|
|
this.openviduService.publishVideo(this.participantService.getMyCameraPublisher(), publishVideo);
|
2022-01-19 17:24:11 +01:00
|
|
|
} catch (error) {
|
|
|
|
this.log.e('There was an error toggling camera:', error.code, error.message);
|
|
|
|
this.actionService.openDialog('There was an error toggling camera:', error?.error || error?.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-01-19 17:24:11 +01:00
|
|
|
async toggleScreenShare() {
|
2022-03-09 15:31:21 +01:00
|
|
|
this.onScreenshareButtonClicked.emit();
|
2022-01-19 17:24:11 +01:00
|
|
|
|
|
|
|
try {
|
|
|
|
// Disabling screenShare
|
2022-02-25 11:19:21 +01:00
|
|
|
if (this.participantService.haveICameraAndScreenActive()) {
|
2022-03-23 13:45:30 +01:00
|
|
|
this.participantService.disableScreenStream();
|
2022-02-15 15:52:59 +01:00
|
|
|
this.openviduService.unpublish(this.participantService.getMyScreenPublisher());
|
2022-01-19 17:24:11 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Enabling screenShare
|
2022-02-25 11:19:21 +01:00
|
|
|
if (this.participantService.isOnlyMyCameraActive()) {
|
|
|
|
const willThereBeWebcam = this.participantService.isMyCameraActive() && this.participantService.hasCameraVideoActive();
|
2022-01-19 17:24:11 +01:00
|
|
|
const hasAudio = willThereBeWebcam ? false : this.hasAudioDevices && this.participantService.hasCameraAudioActive();
|
|
|
|
const properties: PublisherProperties = {
|
|
|
|
videoSource: ScreenType.SCREEN,
|
|
|
|
audioSource: this.hasAudioDevices ? undefined : null,
|
|
|
|
publishVideo: true,
|
|
|
|
publishAudio: hasAudio,
|
|
|
|
mirror: false
|
|
|
|
};
|
2022-02-21 17:33:23 +01:00
|
|
|
const screenPublisher = await this.openviduService.initPublisher(undefined, properties);
|
2022-01-19 17:24:11 +01:00
|
|
|
|
|
|
|
screenPublisher.once('accessAllowed', async (event) => {
|
|
|
|
// Listen to event fired when native stop button is clicked
|
|
|
|
screenPublisher.stream
|
|
|
|
.getMediaStream()
|
|
|
|
.getVideoTracks()[0]
|
|
|
|
.addEventListener('ended', () => {
|
|
|
|
this.log.d('Clicked native stop button. Stopping screen sharing');
|
|
|
|
this.toggleScreenShare();
|
|
|
|
});
|
|
|
|
this.log.d('ACCESS ALOWED screenPublisher');
|
2022-02-25 13:53:49 +01:00
|
|
|
this.participantService.activeMyScreenShare(screenPublisher);
|
2022-01-19 17:24:11 +01:00
|
|
|
|
2022-02-15 15:52:59 +01:00
|
|
|
if (!this.openviduService.isScreenSessionConnected()) {
|
2022-02-24 10:16:23 +01:00
|
|
|
await this.openviduService.connectSession(
|
|
|
|
this.openviduService.getScreenSession(),
|
|
|
|
this.tokenService.getScreenToken()
|
|
|
|
);
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
2022-02-15 15:52:59 +01:00
|
|
|
await this.openviduService.publish(this.participantService.getMyScreenPublisher());
|
|
|
|
// this.openviduService.sendNicknameSignal();
|
2022-01-19 17:24:11 +01:00
|
|
|
if (!this.participantService.hasCameraVideoActive()) {
|
|
|
|
// Disabling webcam
|
2022-03-23 13:45:30 +01:00
|
|
|
this.participantService.disableWebcamStream();
|
2022-02-15 15:52:59 +01:00
|
|
|
this.openviduService.unpublish(this.participantService.getMyCameraPublisher());
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
screenPublisher.once('accessDenied', (error: any) => {
|
|
|
|
this.log.e(error);
|
|
|
|
if (error && error.name === 'SCREEN_SHARING_NOT_SUPPORTED') {
|
|
|
|
this.actionService.openDialog('Error sharing screen', 'Your browser does not support screen sharing');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Disabling screnShare and enabling webcam
|
|
|
|
const hasAudio = this.participantService.hasScreenAudioActive();
|
2022-02-15 15:52:59 +01:00
|
|
|
if (!this.openviduService.isWebcamSessionConnected()) {
|
|
|
|
await this.openviduService.connectSession(this.openviduService.getWebcamSession(), this.tokenService.getWebcamToken());
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
2022-02-15 15:52:59 +01:00
|
|
|
await this.openviduService.publish(this.participantService.getMyCameraPublisher());
|
|
|
|
this.openviduService.publishAudio(this.participantService.getMyScreenPublisher(), false);
|
|
|
|
this.openviduService.publishAudio(this.participantService.getMyCameraPublisher(), hasAudio);
|
2022-03-23 13:45:30 +01:00
|
|
|
this.participantService.enableWebcamStream();
|
|
|
|
this.participantService.disableScreenStream();
|
2022-02-15 15:52:59 +01:00
|
|
|
this.openviduService.unpublish(this.participantService.getMyScreenPublisher());
|
2022-01-19 17:24:11 +01:00
|
|
|
} catch (error) {
|
|
|
|
this.log.e('There was an error toggling screen share:', error.code, error.message);
|
|
|
|
this.actionService.openDialog('There was an error toggling screen share:', error?.error || error?.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-01-19 17:24:11 +01:00
|
|
|
leaveSession() {
|
|
|
|
this.log.d('Leaving session...');
|
2022-02-15 15:52:59 +01:00
|
|
|
this.openviduService.disconnect();
|
2022-03-09 15:31:21 +01:00
|
|
|
this.onLeaveButtonClicked.emit();
|
|
|
|
}
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-03-09 15:31:21 +01:00
|
|
|
toggleParticipantsPanel() {
|
|
|
|
this.onParticipantsPanelButtonClicked.emit();
|
|
|
|
this.menuService.toggleMenu(MenuType.PARTICIPANTS);
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-03-09 15:31:21 +01:00
|
|
|
toggleChatPanel() {
|
|
|
|
this.onChatPanelButtonClicked.emit();
|
|
|
|
this.menuService.toggleMenu(MenuType.CHAT);
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-01-19 17:24:11 +01:00
|
|
|
toggleFullscreen() {
|
2022-02-24 10:16:23 +01:00
|
|
|
this.isFullscreenActive = !this.isFullscreenActive;
|
2022-02-22 16:59:24 +01:00
|
|
|
this.documentService.toggleFullscreen('session-container');
|
2022-03-09 15:31:21 +01:00
|
|
|
this.onFullscreenButtonClicked.emit();
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
protected subscribeToReconnection() {
|
|
|
|
this.session.on('reconnecting', () => {
|
|
|
|
if (this.menuService.isMenuOpened()) {
|
|
|
|
this.menuService.closeMenu();
|
|
|
|
}
|
|
|
|
this.isConnectionLost = true;
|
|
|
|
});
|
|
|
|
this.session.on('reconnected', () => {
|
|
|
|
this.isConnectionLost = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
protected subscribeToMenuToggling() {
|
2022-02-24 10:16:23 +01:00
|
|
|
this.menuTogglingSubscription = this.menuService.menuOpenedObs.subscribe((ev: { opened: boolean; type?: MenuType }) => {
|
2022-01-19 17:24:11 +01:00
|
|
|
this.isChatOpened = ev.opened && ev.type === MenuType.CHAT;
|
|
|
|
this.isParticipantsOpened = ev.opened && ev.type === MenuType.PARTICIPANTS;
|
|
|
|
if (this.isChatOpened) {
|
|
|
|
this.unreadMessages = 0;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
protected subscribeToChatMessages() {
|
|
|
|
this.chatMessagesSubscription = this.chatService.messagesObs.pipe(skip(1)).subscribe((messages) => {
|
|
|
|
if (!this.menuService.isMenuOpened()) {
|
|
|
|
this.unreadMessages++;
|
|
|
|
}
|
|
|
|
this.messageList = messages;
|
2022-02-24 10:20:32 +01:00
|
|
|
this.cd.markForCheck();
|
2022-01-19 17:24:11 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
protected subscribeToUserMediaProperties() {
|
2022-02-25 11:19:21 +01:00
|
|
|
this.localParticipantSubscription = this.participantService.localParticipantObs.subscribe((p) => {
|
2022-03-23 13:45:30 +01:00
|
|
|
if (p) {
|
2022-03-10 14:12:43 +01:00
|
|
|
this.isWebcamVideoActive = p.isCameraVideoActive();
|
|
|
|
this.isWebcamAudioActive = p.isCameraAudioActive();
|
|
|
|
this.isScreenShareActive = p.isScreenActive();
|
|
|
|
this.cd.markForCheck();
|
|
|
|
}
|
2022-01-19 17:24:11 +01:00
|
|
|
});
|
|
|
|
}
|
2022-03-07 15:50:27 +01:00
|
|
|
|
|
|
|
private subscribeToToolbarDirectives() {
|
|
|
|
this.minimalSub = this.libService.minimalObs.subscribe((value: boolean) => {
|
|
|
|
this.isMinimal = value;
|
|
|
|
this.cd.markForCheck();
|
|
|
|
});
|
|
|
|
this.screenshareButtonSub = this.libService.screenshareButtonObs.subscribe((value: boolean) => {
|
|
|
|
this.showScreenshareButton = value;
|
|
|
|
this.cd.markForCheck();
|
|
|
|
});
|
|
|
|
this.fullscreenButtonSub = this.libService.fullscreenButtonObs.subscribe((value: boolean) => {
|
|
|
|
this.showFullscreenButton = value;
|
|
|
|
this.cd.markForCheck();
|
|
|
|
});
|
|
|
|
this.leaveButtonSub = this.libService.leaveButtonObs.subscribe((value: boolean) => {
|
|
|
|
this.showLeaveButton = value;
|
|
|
|
this.cd.markForCheck();
|
|
|
|
});
|
|
|
|
this.chatPanelButtonSub = this.libService.chatPanelButtonObs.subscribe((value: boolean) => {
|
|
|
|
this.showChatPanelButton = value;
|
|
|
|
this.cd.markForCheck();
|
|
|
|
});
|
|
|
|
this.participantsPanelButtonSub = this.libService.participantsPanelButtonObs.subscribe((value: boolean) => {
|
|
|
|
this.showParticipantsPanelButton = value;
|
|
|
|
this.cd.markForCheck();
|
|
|
|
});
|
|
|
|
this.displayLogoSub = this.libService.displayLogoObs.subscribe((value: boolean) => {
|
|
|
|
this.showLogo = value;
|
|
|
|
this.cd.markForCheck();
|
|
|
|
});
|
|
|
|
this.displaySessionNameSub = this.libService.displaySessionNameObs.subscribe((value: boolean) => {
|
|
|
|
this.showSessionName = value;
|
|
|
|
this.cd.markForCheck();
|
|
|
|
});
|
|
|
|
}
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|