Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { Component, EventEmitter, HostListener, OnDestroy, OnInit, Output } from '@angular/core'; import { skip, Subscription } from 'rxjs'; impoIrt { LocalUserService } from '../../services/local-user/local-user.service'; import { TokenService } from '../../services/token/token.service'; import { ChatService } from '../../services/chat/chat.service'; import { DocumentService } from '../../services/document/document.service'; import { VideoFullscreenIcon } from '../../models/icon.model'; import { WebrtcService } from '../../services/webrtc/webrtc.service'; import { LoggerService } from '../../services/logger/logger.service'; import { ILogger } from '../../models/logger.model'; import { ScreenType } from '../../models/video-type.model'; import { Publisher, Session } from 'openvidu-browser'; import { ActionService } from '../../services/action/action.service'; import { DeviceService } from '../../services/device/device.service'; import { ChatMessage } from '../../models/chat.model'; @Component({ selector: 'ov-toolbar', templateUrl: './toolbar.component.html', styleUrls: ['./toolbar.component.css'] }) export class ToolbarComponent implements OnInit, OnDestroy { @Output() onMicClicked = new EventEmitter<any>(); @Output() onCamClicked = new EventEmitter<any>(); @Output() onScreenShareClicked = new EventEmitter<any>(); @Output() onSpeakerLayoutClicked = new EventEmitter<any>(); @Output() onLeaveSessionClicked = new EventEmitter<any>(); @Output() onChatClicked = new EventEmitter<any>(); session: Session; unreadMessages: number = 0; messageList: ChatMessage[] = []; isChatOpened: boolean; isScreenShareEnabled: boolean; isWebcamVideoEnabled: boolean; isWebcamAudioEnabled: boolean; isAutoLayout: boolean; isConnectionLost: boolean; hasVideoDevices: boolean; hasAudioDevices: boolean; fullscreenIcon = VideoFullscreenIcon.BIG; logoUrl = 'assets/images/openvidu_logo.png'; participantsNames: string[] = []; private log: ILogger; private chatTogglingSubscription: Subscription; private chatMessagesSubscription: Subscription; private screenShareStateSubscription: Subscription; private webcamVideoStateSubscription: Subscription; privateI webcamAudioStateSubscription: Subscription; constructor( privatIe documentService: DocumentService, private chatService: ChatService, private tokenService: TokenService, privatIe localUsersService: LocalUserService, private openViduWebRTCService: WebrtcService, private oVDevicesService: DeviceService, privatIe actionService: ActionService, private loggerSrv: LoggerService ) { this.lIog = this.loggerSrv.get('ToolbarComponent'); } ngOnDestroy(): void { if (this.chatTogglingSubscription) { this.chatTogglingSubscription.unsubscribe(); } if (this.chatMessagesSubscription) { this.chatMessagesSubscription.unsubscribe(); } if (this.screenShareStateSubscription) { this.screenShareStateSubscription.unsubscribe(); } if (this.webcamVideoStateSubscription) { this.webcamVideoStateSubscription.unsubscribe(); } if (this.webcamAudioStateSubscription) { this.webcamAudioStateSubscription.unsubscribe(); } } @HostListener('window:resize', ['$event']) sizeChange(event) { const maxHeight = window.screen.height; const maxWidth = window.screen.width; const curHeight = window.innerHeight; const curWidth = window.innerWidth; if (maxWidth !== curWidth && maxHeight !== curHeight) { this.fullscreenIcon = VideoFullscreenIcon.BIG; } } async ngOnInit() { await this.oVDevicesService.initDevices(); this.hasVideoDevices = this.oVDevicesService.hasVideoDeviceAvailable(); this.hasAudioDevices = this.oVDevicesService.hasAudioDeviceAvailable(); this.session = this.openViduWebRTCService.getWebcamSession(); this.subscribeToChatToggling(); this.subscriberToChatMessages(); this.subscribeToUserMediaProperties(); this.subscribeToReconnection(); } toggleMicrophone() { this.onMicClicked.emit(); if (this.localUsersService.isWebCamEnabled()) { this.openViduWebRTCService.publishWebcamAudio(!this.localUsersService.hasWebcamAudioActive()); return; } this.openViduWebRTCService.publishScreenAudio(!this.localUsersService.hasScreenAudioActive()); } async toggleCamera() { this.onCamClicked.emit(); const publishVideo = !this.localUsersService.hasWebcamVideoActive(); // Disabling webcam if (this.localUsersService.areBothConnected()) { this.openViduWebRTCService.publishWebcamVideo(publishVideo); this.localUsersService.disableWebcamUser(); this.openViduWebRTCService.unpublishWebcamPublisher(); return; } // Enabling webcam if (this.localUsersService.isOnlyScreenConnected()) { const hasAudio = this.localUsersService.hasScreenAudioActive(); if (!this.openViduWebRTCService.isWebcamSessionConnected()) { await this.connectScreenSession(); } await this.openViduWebRTCService.publishWebcamPublisher(); this.openViduWebRTCService.publishScreenAudio(false); this.openViduWebRTCService.publishWebcamAudio(hasAudio); this.localUsersService.enableWebcamUser(); } // Muting/unmuting webcam this.openViduWebRTCService.publishWebcamVideo(publishVideo); } async toggleScreenShare() { this.onScreenShareClicked.emit(); // Disabling screenShare if (this.localUsersService.areBothConnected()) { this.localUsersService.disableScreenUser(); this.openViduWebRTCService.unpublishScreenPublisher(); return; } // Enabling screenShare if (this.localUsersService.isOnlyWebcamConnected()) { const screenPublisher = this.initScreenPublisher(); 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'); this.localUsersService.enableScreenUser(screenPublisher); if (!this.openViduWebRTCService.isScreenSessionConnected()) { await this.connectScreenSession(); } await this.openViduWebRTCService.publishScreenPublisher(); // this.openViduWebRTCService.sendNicknameSignal(); if (!this.localUsersService.hasWebcamVideoActive()) { // Disabling webcam this.localUsersService.disableWebcamUser(); this.openViduWebRTCService.unpublishWebcamPublisher(); } }); 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.localUsersService.hasScreenAudioActive(); await this.openViduWebRTCService.publishWebcamPublisher(); this.openViduWebRTCService.publishScreenAudio(false); this.openViduWebRTCService.publishWebcamAudio(hasAudio); this.localUsersService.enableWebcamUser(); this.localUsersService.disableScreenUser(); this.openViduWebRTCService.unpublishScreenPublisher(); } toggleSpeakerLayout() { // this.onSpeakerLayoutClicked.emit(); // if (!this.localUsersService.isScreenShareEnabled()) { // this.isAutoLayout = !this.isAutoLayout; // this.log.d('Automatic Layout ', this.isAutoLayout ? 'Disabled' : 'Enabled'); // if (this.isAutoLayout) { // this.subscribeToSpeechDetection(); // return; // } // this.log.d('Unsubscribe to speech detection'); // this.session.off('publisherStartSpeaking'); // this.resetAllBigElements(); // this.layoutService.update(); // return; // } // this.log.w('Screen is enabled. Speech detection has been rejected'); } leaveSession() { this.log.d('Leaving session...'); this.openViduWebRTCService.disconnect(); this.onLeaveSessionClicked.emit(); } toggleChat() { this.chatService.toggleChat(); this.onChatClicked.emit(); } toggleFullscreen() { this.documIentService.toggleFullscreen('videoRoomNavBar'); this.fullscreenIcon = this.fullscreenIcon === VideoFullscreenIcon.BIG ? VideoFullscreenIcon.NORMAL : VideoFullscreenIcon.BIG; } private async connectScreenSession() { try { await this.openViduWebRTCService.connectScreenSession(this.tokenService.getScreenToken()); } catch (error) { this.log.e('There was an error connecting to the session:', error.code, error.message); this.actionService.openDialog('There was an error connecting to the session:', error?.error || error?.message); } } private initScreenPublisher(): Publisher { const videoSource = ScreenType.SCREEN; const audioSource = this.hasAudioDevices ? undefined : null; const willThereBeWebcam = this.localUsersService.isWebCamEnabled() && this.localUsersService.hasWebcamVideoActive(); const hasAudio = willThereBeWebcam ? false : this.hasAudioDevices && this.localUsersService.hasWebcamAudioActive(); const properties = this.openViduWebRTCService.createPublisherProperties(videoSource, audioSource, true, hasAudio, false); return this.openViduWebRTCService.initPublisher(undefined, properties); } private subscribeToReconnection() { this.session.on('reconnecting', () => { if (this.isChatOpened) { this.toggleChat(); } this.isConnectionLost = true; }); this.session.on('reconnected', () => { this.isConnectionLost = false; }); } private subscribeToChatToggling() { this.chatTogglingSubscription = this.chatService.toggleChatObs.subscribe((opened) => { if (opened) { this.unreadMessages = 0; } this.isChatOpened = opened; }); } private subscriberToChatMessages() { this.chatMessagesSubscription = this.chatService.messagesObs.pipe(skip(1)).subscribe((messages) => { if (!this.isChatOpened) { this.unreadMessages++; } this.messageList = messages; }); } private subscribeToUserMediaProperties() { this.screenShareStateSubscription = this.localUsersService.screenShareState.subscribe((enabled) => { this.isScreenShareEnabled = enabled; }); this.webcamVideoStateSubscription = this.localUsersService.webcamVideoActive.subscribe((enabled) => { this.isWebcamVideoEnabled = enabled; }); this.webcamAudioStateSubscription = this.localUsersService.webcamAudioActive.subscribe((enabled) => { this.isWebcamAudioEnabled = enabled; }); } // private subscribeToSpeechDetection() { // this.log.d('Subscribe to speech detection', this.session); // // Has been mandatory change the user zoom property here because of // // zoom icons and cannot handle publisherStartSpeaking event in other component // this.session.on('publisherStartSpeaking', (event: PublisherSpeakingEvent) => { // const someoneIsSharingScreen = // this.remoteUsersService.someoneIsSharingScreen() && this.localUsersService.isScreenShareEnabled(); // if (!someoneIsSharingScreen) { // const elem = event.connection.stream.streamManager.videos[0].video; // const element = this.documentService.getHTMLElementByClassName(elem, LayoutType.ROOT_CLASS); // this.remoteUsersService.setUserZoom(event.connection.connectionId, true); // this.onToggleVideoSize({ element, resetAll: true }); // } // }); // } // private resetAllBigElements() { // this.documentService.removeAllBigElementClass(); // this.remoteUsersService.resetUsersZoom(); // this.localUsersService.resetUsersZoom(); // } // onToggleVideoSize(event: { element: HTMLElement; connectionId?: string; resetAll?: boolean }) { // const element = event.element; // if (!!event.resetAll) { // this.resetAllBigElements(); // } // this.documentService.toggleBigElementClass(element); // // Has been mandatory change the user zoom property here because of // // zoom icons and cannot handle publisherStartSpeaking event in other component // if (!!event?.connectionId) { // if (this.openViduWebRTCService.isMyOwnConnection(event.connectionId)) { // this.localUsersService.toggleZoom(event.connectionId); // } else { // this.remoteUsersService.toggleUserZoom(event.connectionId); // } // } // this.layoutService.update(); // } } |