mirror of https://github.com/OpenVidu/openvidu.git
openvidu-components: Refactored video enlarged feature
parent
28fe810f06
commit
bb8f0b752f
|
@ -2,7 +2,7 @@
|
||||||
*ngIf="this._stream"
|
*ngIf="this._stream"
|
||||||
class="OT_widget-container"
|
class="OT_widget-container"
|
||||||
[id]="'container-' + this._stream.streamManager?.stream?.streamId"
|
[id]="'container-' + this._stream.streamManager?.stream?.streamId"
|
||||||
#streamComponent
|
#streamContainer
|
||||||
>
|
>
|
||||||
<div class="nickname" [class.fullscreen]="isFullscreen">
|
<div class="nickname" [class.fullscreen]="isFullscreen">
|
||||||
<div (click)="toggleNicknameForm()" class="nicknameContainer" selected *ngIf="!toggleNickname">
|
<div (click)="toggleNicknameForm()" class="nicknameContainer" selected *ngIf="!toggleNickname">
|
||||||
|
@ -32,10 +32,9 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ov-video
|
<ov-video
|
||||||
(dblclick)="toggleVideoSize()"
|
(dblclick)="toggleVideoEnlarged()"
|
||||||
[streamManager]="this._stream.streamManager"
|
[streamManager]="this._stream.streamManager"
|
||||||
[mutedSound]="mutedSound"
|
[mutedSound]="mutedSound"
|
||||||
(toggleVideoSizeEvent)="toggleVideoSize($event)"
|
|
||||||
></ov-video>
|
></ov-video>
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,7 +60,7 @@
|
||||||
</button>
|
</button>
|
||||||
<span [matMenuTriggerFor]="menu"></span>
|
<span [matMenuTriggerFor]="menu"></span>
|
||||||
<mat-menu #menu="matMenu" yPosition="above" xPosition="before">
|
<mat-menu #menu="matMenu" yPosition="above" xPosition="before">
|
||||||
<button mat-menu-item id="videoZoomButton" (click)="toggleVideoSize()">
|
<button mat-menu-item id="videoZoomButton" (click)="toggleVideoEnlarged()">
|
||||||
<mat-icon>{{ this.videoSizeIcon }}</mat-icon>
|
<mat-icon>{{ this.videoSizeIcon }}</mat-icon>
|
||||||
<span *ngIf="videoSizeIcon === videoSizeIconEnum.NORMAL">Zoom out</span>
|
<span *ngIf="videoSizeIcon === videoSizeIconEnum.NORMAL">Zoom out</span>
|
||||||
<span *ngIf="videoSizeIcon === videoSizeIconEnum.BIG">Zoom in</span>
|
<span *ngIf="videoSizeIcon === videoSizeIconEnum.BIG">Zoom in</span>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Component, ContentChild, ElementRef, HostListener, Input, OnInit, TemplateRef, ViewChild, ViewContainerRef } from '@angular/core';
|
import { Component, ContentChild, ElementRef, HostListener, Input, OnInit, TemplateRef, ViewChild } from '@angular/core';
|
||||||
import { FormControl, Validators } from '@angular/forms';
|
import { FormControl, Validators } from '@angular/forms';
|
||||||
import { MatMenuPanel, MatMenuTrigger } from '@angular/material/menu';
|
import { MatMenuPanel, MatMenuTrigger } from '@angular/material/menu';
|
||||||
import { NicknameMatcher } from '../../matchers/nickname.matcher';
|
import { NicknameMatcher } from '../../matchers/nickname.matcher';
|
||||||
|
@ -32,8 +32,7 @@ export class StreamComponent implements OnInit {
|
||||||
nicknameFormControl: FormControl;
|
nicknameFormControl: FormControl;
|
||||||
matcher: NicknameMatcher;
|
matcher: NicknameMatcher;
|
||||||
_stream: StreamModel;
|
_stream: StreamModel;
|
||||||
|
private _streamContainer: ElementRef;
|
||||||
@ViewChild('streamComponent', { read: ViewContainerRef }) streamComponent: ViewContainerRef;
|
|
||||||
@ViewChild(MatMenuTrigger) public menuTrigger: MatMenuTrigger;
|
@ViewChild(MatMenuTrigger) public menuTrigger: MatMenuTrigger;
|
||||||
@ViewChild('menu') menu: MatMenuPanel;
|
@ViewChild('menu') menu: MatMenuPanel;
|
||||||
|
|
||||||
|
@ -54,11 +53,22 @@ export class StreamComponent implements OnInit {
|
||||||
// this.isFullscreenEnabled = !this.isFullscreenEnabled;
|
// this.isFullscreenEnabled = !this.isFullscreenEnabled;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
@ViewChild('streamContainer', { static: false, read: ElementRef })
|
||||||
|
set streamContainer(streamContainer: ElementRef) {
|
||||||
|
setTimeout(() => {
|
||||||
|
if (streamContainer) {
|
||||||
|
this._streamContainer = streamContainer;
|
||||||
|
if (this._stream.type === VideoType.SCREEN) {
|
||||||
|
this.toggleVideoEnlarged(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
set stream(stream: StreamModel) {
|
set stream(stream: StreamModel) {
|
||||||
this._stream = stream;
|
this._stream = stream;
|
||||||
this.checkVideoSizeBigIcon(this._stream.videoEnlarged);
|
this.checkVideoEnlarged();
|
||||||
this.nicknameFormControl = new FormControl(this._stream.nickname, [Validators.maxLength(25), Validators.required]);
|
this.nicknameFormControl = new FormControl(this._stream.nickname, [Validators.maxLength(25), Validators.required]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,21 +87,21 @@ export class StreamComponent implements OnInit {
|
||||||
this.cdkSrv.setSelector('body');
|
this.cdkSrv.setSelector('body');
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleVideoSize(resetAll?) {
|
toggleVideoEnlarged(resetAll?) {
|
||||||
const element = this.documentService.getHTMLElementByClassName(this.streamComponent.element.nativeElement, LayoutClass.ROOT_ELEMENT);
|
const element = this.documentService.getHTMLElementByClassName(this._streamContainer.nativeElement, LayoutClass.ROOT_ELEMENT);
|
||||||
if (!!resetAll) {
|
if (!!resetAll) {
|
||||||
this.documentService.removeAllBigElementClass();
|
this.documentService.removeAllBigElementClass();
|
||||||
this.participantService.resetUsersZoom();
|
this.participantService.resetMyVideoEnlarged();
|
||||||
this.participantService.resetUsersZoom();
|
this.participantService.resetRemotesVideoEnlarged();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.documentService.toggleBigElementClass(element);
|
this.documentService.toggleBigElementClass(element);
|
||||||
|
|
||||||
if (!!this._stream.streamManager?.stream?.connection?.connectionId) {
|
if (!!this._stream.streamManager?.stream?.connection?.connectionId) {
|
||||||
if (this.openViduWebRTCService.isMyOwnConnection(this._stream.streamManager?.stream?.connection?.connectionId)) {
|
if (this.openViduWebRTCService.isMyOwnConnection(this._stream.streamManager?.stream?.connection?.connectionId)) {
|
||||||
this.participantService.toggleZoom(this._stream.streamManager?.stream?.connection?.connectionId);
|
this.participantService.toggleMyVideoEnlarged(this._stream.streamManager?.stream?.connection?.connectionId);
|
||||||
} else {
|
} else {
|
||||||
this.participantService.toggleUserZoom(this._stream.streamManager?.stream?.connection?.connectionId);
|
this.participantService.toggleRemoteVideoEnlarged(this._stream.streamManager?.stream?.connection?.connectionId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.layoutService.update();
|
this.layoutService.update();
|
||||||
|
@ -136,8 +146,7 @@ export class StreamComponent implements OnInit {
|
||||||
await this.openViduWebRTCService.replaceTrack(this.participantService.getMyScreenPublisher(), properties);
|
await this.openViduWebRTCService.replaceTrack(this.participantService.getMyScreenPublisher(), properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected checkVideoSizeBigIcon(videoEnlarged: boolean) {
|
protected checkVideoEnlarged() {
|
||||||
this.videoSizeIcon = videoEnlarged ? VideoSizeIcon.NORMAL : VideoSizeIcon.BIG;
|
this.videoSizeIcon = this._stream.videoEnlarged ? VideoSizeIcon.NORMAL : VideoSizeIcon.BIG;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
import { AfterViewInit, Component, ElementRef, Input, EventEmitter, Output, ViewChild } from '@angular/core';
|
import { AfterViewInit, Component, ElementRef, Input, ViewChild } from '@angular/core';
|
||||||
import { StreamManager } from 'openvidu-browser';
|
import { StreamManager } from 'openvidu-browser';
|
||||||
import { VideoType } from '../../models/video-type.model';
|
import { VideoType } from '../../models/video-type.model';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ov-video',
|
selector: 'ov-video',
|
||||||
template: `
|
template: `
|
||||||
<img *ngIf="!_streamManager?.stream?.videoActive && (type === 'CAMERA' || !type)" class="poster_img" alt="OpenVidu Logo" src="assets/images/poster.png" />
|
<img
|
||||||
|
*ngIf="!_streamManager?.stream?.videoActive && (type === 'CAMERA' || !type)"
|
||||||
|
class="poster_img"
|
||||||
|
alt="OpenVidu Logo"
|
||||||
|
src="assets/images/poster.png"
|
||||||
|
/>
|
||||||
<video
|
<video
|
||||||
#videoElement
|
#videoElement
|
||||||
[attr.id]="streamManager && _streamManager.stream ? 'video-' + _streamManager.stream.streamId : 'video-undefined'"
|
[attr.id]="streamManager && _streamManager.stream ? 'video-' + _streamManager.stream.streamId : 'video-undefined'"
|
||||||
|
@ -17,8 +22,6 @@ import { VideoType } from '../../models/video-type.model';
|
||||||
export class VideoComponent implements AfterViewInit {
|
export class VideoComponent implements AfterViewInit {
|
||||||
@Input() mutedSound: boolean;
|
@Input() mutedSound: boolean;
|
||||||
|
|
||||||
@Output() toggleVideoSizeEvent = new EventEmitter<any>();
|
|
||||||
|
|
||||||
_streamManager: StreamManager;
|
_streamManager: StreamManager;
|
||||||
|
|
||||||
_videoElement: ElementRef;
|
_videoElement: ElementRef;
|
||||||
|
@ -45,8 +48,7 @@ export class VideoComponent implements AfterViewInit {
|
||||||
this.type = <VideoType>this._streamManager?.stream?.typeOfVideo;
|
this.type = <VideoType>this._streamManager?.stream?.typeOfVideo;
|
||||||
if (this.type === VideoType.SCREEN) {
|
if (this.type === VideoType.SCREEN) {
|
||||||
this._videoElement.nativeElement.style.objectFit = 'contain';
|
this._videoElement.nativeElement.style.objectFit = 'contain';
|
||||||
this._videoElement.nativeElement.style.background = '#272727';
|
// this._videoElement.nativeElement.style.background = '#272727';
|
||||||
this.enableVideoSizeBig();
|
|
||||||
} else {
|
} else {
|
||||||
this._videoElement.nativeElement.style.objectFit = 'cover';
|
this._videoElement.nativeElement.style.objectFit = 'cover';
|
||||||
}
|
}
|
||||||
|
@ -54,12 +56,4 @@ export class VideoComponent implements AfterViewInit {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
enableVideoSizeBig() {
|
|
||||||
// Doing video size bigger.
|
|
||||||
// Timeout because of connectionId is null and icon does not change
|
|
||||||
setTimeout(() => {
|
|
||||||
this.toggleVideoSizeEvent.emit(true);
|
|
||||||
}, 590);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,11 +139,11 @@ export class ParticipantService {
|
||||||
return this.localParticipant.getScreenNickname();
|
return this.localParticipant.getScreenNickname();
|
||||||
}
|
}
|
||||||
|
|
||||||
resetUsersZoom() {
|
resetMyVideoEnlarged() {
|
||||||
this.localParticipant?.setAllVideoEnlarged(false);
|
this.localParticipant?.setAllVideoEnlarged(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleZoom(connectionId: string) {
|
toggleMyVideoEnlarged(connectionId: string) {
|
||||||
this.localParticipant.toggleVideoEnlarged(connectionId);
|
this.localParticipant.toggleVideoEnlarged(connectionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,12 +263,12 @@ export class ParticipantService {
|
||||||
return this.remoteParticipants.some((p) => p.someHasVideoEnlarged());
|
return this.remoteParticipants.some((p) => p.someHasVideoEnlarged());
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleUserZoom(connectionId: string) {
|
toggleRemoteVideoEnlarged(connectionId: string) {
|
||||||
const p = this.getRemoteParticipantByConnectionId(connectionId);
|
const p = this.getRemoteParticipantByConnectionId(connectionId);
|
||||||
p.toggleVideoEnlarged(connectionId);
|
p.toggleVideoEnlarged(connectionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
resetRemotesZoom() {
|
resetRemotesVideoEnlarged() {
|
||||||
this.remoteParticipants.forEach((u) => u.setAllVideoEnlarged(false));
|
this.remoteParticipants.forEach((u) => u.setAllVideoEnlarged(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue