All files / src/lib/components/video video.component.ts

55.17% Statements 16/29
37.5% Branches 12/32
55.55% Functions 5/9
50% Lines 12/24

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 641x 1x 1x 1x 1x         1x   1x     1x 1x           1x                                                   1x           1x                    
import { AfterViewInit, Component, ElementRef, Input, EventEmitter, Output, ViewChild } from '@angular/core';
import { StreamManager } from 'openvidu-browser';
impoIrt { VideoType } from '../../models/video-type.model';

@Component({
	selector: 'ov-video',
	template: `
		<img *ngIf="!_streamManager?.stream?.videoActive" class="poster_img" alt="OpenVidu Logo" src="assets/images/poster.png" />
		<video
			#videoElement
			[attr.id]="streamManager && _streamManager.stream ? 'video-' + _streamManager.stream.streamId : 'video-undefined'"
			[muted]="mutedSound"
		></video>
	`,
	styleUrls: ['./video.component.css']
})I
export class VideoComponent implements AfterViewInit {
	@Input() mutedSound: boolean;
 
	@Output() toggleVideoSizeEvent = new EventEmitter<any>();
 
	_streamManager: StreamManager;
 
	_videoElement: ElementRef;

	ngAfterViewInit() {
		setTimeout(() => {
			if (this._streamManager && this._videoElement) {
				this._streamManager.addVideoElement(this._videoElement.nativeElement);
			}
		});
	}
 
	@ViewChild('videoElement')
	set videoElement(element: ElementRef) {
		this._videoElement = element;
	}
 
	@Input()
	set streamManager(streamManager: StreamManager) {
		setTimeout(() => {
			this._streamManager = streamManager;
			if (!!this._videoElement && this._streamManager) {
				if (this._streamManager.stream.typeOfVideo === VideoType.SCREEN) {
					this._videoElement.nativeElement.style.objectFit = 'contain';
					this._videoElement.nativeElement.style.background = '#272727';
					this.enableVideoSizeBig();
				} else {
					this._videoElement.nativeElement.style.objectFit = 'cover';
				}
				this._streamManager.addVideoElement(this._videoElement.nativeElement);
			}
		});
	}
 
	enableVideoSizeBig() {
		// Doing video size bigger.
		// Timeout because of connectionId is null and icon does not change
		setTimeout(() => {
			this.toggleVideoSizeEvent.emit(true);
		}, 590);
	}
}