import { Injectable } from '@angular/core' ; import { OpenViduLayoutOptions , OpenViduLayout } from '../../layout/openvidu-layout' ; import { LayoutClass } from '../../types/layout-type' ; @ Injectable ( { providedIn : 'root' } ) export class OpenViduLayoutService { private openviduLayout : OpenViduLayout ; private openviduLayoutOptions : OpenViduLayoutOptions ; constructor ( ) { } initialize ( timeout = null ) { if ( ! ! timeout ) { setTimeout ( ( ) => { this . _initialize ( ) ; } , timeout ) ; } else { this . _initialize ( ) ; } } private _initialize ( ) { this . openviduLayout = new OpenViduLayout ( ) ; this . openviduLayoutOptions = this . getOptions ( ) ; this . openviduLayout . initLayoutContainer ( document . getElementById ( 'layout' ) , this . openviduLayoutOptions ) ; } getOptions ( ) { const options = { maxRatio : 3 / 2 , minRatio : 9 / 15 , fixedRatio : false , bigClass : LayoutClass . BIG_ELEMENT , smallClass : LayoutClass . SMALL_ELEMENT , bigPercentage : 0.85 , bigFixedRatio : false , bigMaxRatio : 3 / 2 , bigMinRatio : 9 / 16 , bigFirst : true , animate : true } ; return options ; } update ( timeout ? ) { if ( ! ! this . openviduLayout ) { if ( ! timeout ) { this . openviduLayout . updateLayout ( ) ; return ; } setTimeout ( ( ) => { this . openviduLayout . updateLayout ( ) ; } , timeout ) ; } } getLayout ( ) { return this . openviduLayout ; } clear ( ) { this . openviduLayout = null ; } }