2018-12-31 01:03:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								import  Debug  from  '../../conf/Debug' ;  
						 
					
						
							
								
									
										
										
										
											2019-03-10 23:27:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								import  AspectRatio  from  '../../../common/enums/aspect-ratio.enum' ;  
						 
					
						
							
								
									
										
										
										
											2018-12-31 01:03:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-05-06 21:32:18 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// računa velikost videa za približevanje/oddaljevanje
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// does video size calculations for zooming/cropping
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								class  Scaler  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  // internal variables
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  // functions
 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-18 23:26:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								  constructor ( videoData )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    this . conf  =  videoData ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-06 21:32:18 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  } 
							 
						 
					
						
							
								
									
										
										
										
											2019-03-10 23:27:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								  
							 
						 
					
						
							
								
									
										
										
										
											2019-05-05 00:09:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  // Skrbi za "stare" možnosti, kot na primer "na širino zaslona", "na višino zaslona" in "ponastavi". 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  // Približevanje opuščeno.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  // handles "legacy" options, such as 'fit to widht', 'fit to height' and AspectRatio.Reset. No zoom tho
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  modeToAr  ( ar )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-07 23:40:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ar . type  !==  AspectRatio . FitWidth  &&  ar . type  !==  AspectRatio . FitHeight  &&  ar . ratio )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-03-10 23:27:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								      return  ar . ratio ;  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-05 00:09:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-03-10 23:27:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    var  ratioOut ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-06 21:32:18 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-05-22 00:19:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! this . conf . video )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-06 21:32:18 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      if ( Debug . debug ) { 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-22 00:19:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        console . log ( "[Scaler.js::modeToAr] No video??" , this . conf . video ,  "killing videoData" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-06 21:32:18 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      } 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-18 23:26:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								      this . conf . destroy ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-06 21:32:18 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      return  null ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    
							 
						 
					
						
							
								
									
										
										
										
											2018-05-23 00:34:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if ( !  this . conf . player . dimensions  ) { 
							 
						 
					
						
							
								
									
										
										
										
											2019-03-10 23:27:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								      ratioOut  =  screen . width  /  screen . height ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-06 21:32:18 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    else  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-03-10 23:27:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								      ratioOut  =  this . conf . player . dimensions . width  /  this . conf . player . dimensions . height ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-06 21:32:18 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    
							 
						 
					
						
							
								
									
										
										
										
											2018-08-20 22:45:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // POMEMBNO: lastAr je potrebno nastaviti šele po tem, ko kličemo _res_setAr(). _res_setAr() predvideva,
 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-06 21:32:18 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // da želimo nastaviti statično (type: 'static') razmerje stranic — tudi, če funkcijo kličemo tu oz. v ArDetect.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //
 
							 
						 
					
						
							
								
									
										
										
										
											2018-08-20 22:45:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // IMPORTANT NOTE: lastAr needs to be set after _res_setAr() is called, as _res_setAr() assumes we're
 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-06 21:32:18 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // setting a static aspect ratio (even if the function is called from here or ArDetect). 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    
							 
						 
					
						
							
								
									
										
										
										
											2018-05-22 00:19:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    var  fileAr  =  this . conf . video . videoWidth  /  this . conf . video . videoHeight ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-06 21:32:18 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      
							 
						 
					
						
							
								
									
										
										
										
											2019-03-10 23:27:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ar . type  ===  AspectRatio . FitWidth ) { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      ratioOut  >  fileAr  ?  ratioOut  :  fileAr 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      ar . ratio  =  ratioOut ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      return  ratioOut ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-06 21:32:18 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2019-03-10 23:27:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    else  if ( ar . type  ===  AspectRatio . FitHeight ) { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      ratioOut  <  fileAr  ?  ratioOut  :  fileAr 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      ar . ratio  =  ratioOut ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      return  ratioOut ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-06 21:32:18 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2019-03-10 23:27:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    else  if ( ar . type  ===  AspectRatio . Reset ) { 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-06 21:32:18 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      if ( Debug . debug ) { 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-13 15:22:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        console . log ( "[Scaler.js::modeToAr] Using original aspect ratio -" ,  fileAr ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-06 21:32:18 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      } 
							 
						 
					
						
							
								
									
										
										
										
											2019-03-10 23:27:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								      ar . ar  =  fileAr ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-06 21:32:18 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      return  fileAr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  null ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-03-10 23:27:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								  calculateCrop ( ar )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-07 23:40:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if ( ! this . conf . video ) { 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-05 00:09:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								      if  ( Debug . debug )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-07 23:40:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
										 
							
							
								        console . log ( "[Scaler::calculateCrop] ERROR — no video detected. Conf:" ,  this . conf ,  "video:" ,  this . conf . video ,  "video dimensions:" ,  this . conf . video  &&  this . conf . video . videoWidth ,  '×  ,  this . conf . video  &&  this . conf . video . videoHeight ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-05 00:09:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								      } 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-18 23:26:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								      
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      this . conf . destroy ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-16 23:26:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								      return  { error :  "no_video" } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-07 23:40:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( this . conf . video . videoWidth  ==  0  ||  this . conf . video . videoHeight  ==  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      // that's illegal, but not illegal enough to just blast our shit to high hell
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      // mr officer will let you go with a warning this time around
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      if  ( Debug . debug )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								        console . log ( "[Scaler::calculateCrop] Video has illegal dimensions. Video dimensions:" ,  this . conf . video  &&  this . conf . video . videoWidth ,  '×  ,  this . conf . video  &&  this . conf . video . videoHeight ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      return  { error :  "illegal_video_dimensions" } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-16 23:26:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-03-10 23:27:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ar . type  ===  AspectRatio . Reset ) { 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-27 01:29:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								      return  { xFactor :  1 ,  yFactor :  1 } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-05-06 21:32:18 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // handle fuckie-wuckies
 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-05 00:09:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! ar . ratio ) { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      if  ( Debug . debug  &&  Debug . scaler )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-25 22:02:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        console . log ( "[Scaler::calculateCrop] no ar?" ,  ar . ratio ,  " -- we were given this mode:" ,  ar ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-05 00:09:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								      } 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-25 22:02:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								      return  { error :  "no_ar" ,  ratio :  ar . ratio } ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-06 21:32:18 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-05-05 00:09:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( Debug . debug  &&  Debug . scaler )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-25 22:02:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
										 
							
							
								      console . log ( "[Scaler::calculateCrop] trying to set ar. args are: ar->" , ar . ratio , "; this.conf.player.dimensions->" , this . conf . player . dimensions . width ,  "×  ,  this . conf . player . dimensions . height ,  "| obj:" ,  this . conf . player . dimensions ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-05 00:09:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-06 21:32:18 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-05-23 00:34:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if (  ( !  this . conf . player . dimensions )  ||  this . conf . player . dimensions . width  ===  0  ||  this . conf . player . dimensions . height  ===  0  ) { 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-05 00:09:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								      if  ( Debug . debug  &&  Debug . scaler )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-23 00:34:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        console . log ( "[Scaler::calculateCrop] ERROR — no (or invalid) this.conf.player.dimensions:" , this . conf . player . dimensions ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-05 00:09:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								      } 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-23 00:34:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								      return  { error :  "this.conf.player.dimensions_error" } ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-06 21:32:18 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // zdaj lahko končno začnemo računati novo velikost videa
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // we can finally start computing required video dimensions now:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Dejansko razmerje stranic datoteke/<video> značke
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Actual aspect ratio of the file/<video> tag
 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-22 00:19:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    var  fileAr  =  this . conf . video . videoWidth  /  this . conf . video . videoHeight ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-23 00:34:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    var  playerAr  =  this . conf . player . dimensions . width  /  this . conf . player . dimensions . height ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-06 21:32:18 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-05-05 00:09:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ar . type  ===  AspectRatio . Initial  ||  ! ar . ratio )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-25 22:02:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								      ar . ratio  =  fileAr ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-05 00:09:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-06 21:32:18 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  
							 
						 
					
						
							
								
									
										
										
										
											2019-05-05 00:09:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( Debug . debug  &&  Debug . scaler )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-25 22:02:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
										 
							
							
								      console . log ( "[Scaler::calculateCrop] ar is "  , ar . ratio ,  ", file ar is" ,  fileAr ,  ", this.conf.player.dimensions are " ,  this . conf . player . dimensions . width ,  "×  ,  this . conf . player . dimensions . height ,  "| obj:" ,  this . conf . player . dimensions ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-05 00:09:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-06 21:32:18 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    var  videoDimensions  =  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-24 22:49:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								      xFactor :  1 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      yFactor :  1 , 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-06 21:32:18 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      actualWidth :  0 ,    // width of the video (excluding pillarbox) when <video> tag height is equal to width
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      actualHeight :  0 ,   // height of the video (excluding letterbox) when <video> tag height is equal to height
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  
							 
						 
					
						
							
								
									
										
										
										
											2018-05-24 22:49:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // if(Debug.debug){
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								    //   console.log("[Scaler::calculateCrop] Player dimensions?", this.conf.player.dimensions.width, "×  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // }
 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-06 21:32:18 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  
							 
						 
					
						
							
								
									
										
										
										
											2019-05-05 00:09:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( fileAr  <  ar . ratio ) { 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-06 21:32:18 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      // imamo letterbox zgoraj in spodaj -> spremenimo velikost videa (a nikoli širše od ekrana)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      // letterbox -> change video size (but never to wider than monitor width)
 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-05 00:09:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // if (Debug.debug && Debug.scaler) {
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //   console.log(`%c[Scaler::calculateCrop] Trying to determine scaling factors. Aspect ratios:\n      file: ${fileAr.toFixed(3)}\n    player: ${playerAr.toFixed(3)}\n    target: ${ar.ratio.toFixed(3)}\n-----------------------`, "color: #2ba");
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // }
 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-25 22:02:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        videoDimensions . xFactor  =  Math . min ( ar . ratio ,  playerAr )  /  fileAr ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-24 22:49:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        videoDimensions . yFactor  =  videoDimensions . xFactor ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-05 00:09:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-25 22:02:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        videoDimensions . xFactor  =  fileAr  /  Math . min ( ar . ratio ,  playerAr ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-24 22:49:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        videoDimensions . yFactor  =  videoDimensions . xFactor ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-06 21:32:18 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    
							 
						 
					
						
							
								
									
										
										
										
											2019-05-05 00:39:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( Debug . debug  &&  Debug . scaler )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-24 22:49:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								      console . log ( "[Scaler::calculateCrop] Crop factor calculated — " ,  videoDimensions . xFactor ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-06 21:32:18 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  videoDimensions ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								  } 
							 
						 
					
						
							
								
									
										
										
										
											2018-12-31 01:03:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								export  default  Scaler ;