import { Component , Input , ViewChild , ElementRef , AfterViewInit , Output , EventEmitter } from '@angular/core' ; import { StreamManager } from 'openvidu-browser' ; import { VideoType } from '../../types/video-type' ; @ 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 : [ './stream.component.css' ] } ) export class OpenViduVideoComponent 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 ) { this . _videoElement = element ; } @ Input ( ) set 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 ( ) { setTimeout ( ( ) => { this . toggleVideoSizeEvent . emit ( true ) ; } , 590 ) ; } }