import { SiteSettings } from './../settings/SiteSettings'; import StretchType from '../../../common/enums/StretchType.enum'; import BrowserDetect from '../../conf/BrowserDetect'; import AspectRatioType from '../../../common/enums/AspectRatioType.enum'; import VideoData from '../video-data/VideoData'; import Logger from '../Logger'; import Settings from '../Settings'; import { Stretch } from '../../../common/interfaces/StretchInterface'; // računa vrednosti za transform-scale (x, y) // transform: scale(x,y) se uporablja za raztegovanje videa, ne pa za približevanje // calculates values for transform scale(x, y) // transform: scale(x,y) is used for stretching, not zooming. class Stretcher { //#region flags //#endregion //#region helper objects conf: VideoData; logger: Logger; settings: Settings; siteSettings: SiteSettings; //#endregion //#region misc data stretch: Stretch; fixedStretchRatio: any; //#endregion // functions constructor(videoData) { this.conf = videoData; this.logger = videoData.logger; this.siteSettings = videoData.siteSettings; this.settings = videoData.settings; this.setStretchMode(this.siteSettings.getDefaultOption('stretch') as Stretch); } setStretchMode(stretch: Stretch) { this.stretch = stretch; } applyConditionalStretch(stretchFactors, actualAr){ let playerAr = this.conf.player.aspectRatio; let videoAr = this.conf.aspectRatio; if (! actualAr){ actualAr = playerAr; } let newWidth = this.conf.video.offsetWidth * stretchFactors.xFactor; let newHeight = this.conf.video.offsetHeight * stretchFactors.yFactor; let actualWidth, actualHeight; // determine the dimensions of the video (sans black bars) after scaling if(actualAr < videoAr){ actualHeight = newHeight; actualWidth = newHeight * actualAr; } else { actualHeight = newWidth / actualAr; actualWidth = newWidth; } let minW = this.conf.player.dimensions.width * (1 - this.settings.active.stretch.conditionalDifferencePercent); let maxW = this.conf.player.dimensions.width * (1 + this.settings.active.stretch.conditionalDifferencePercent); let minH = this.conf.player.dimensions.height * (1 - this.settings.active.stretch.conditionalDifferencePercent); let maxH = this.conf.player.dimensions.height * (1 + this.settings.active.stretch.conditionalDifferencePercent); if (actualWidth >= minW && actualWidth <= maxW) { stretchFactors.xFactor *= this.conf.player.dimensions.width / actualWidth; } if (actualHeight >= minH && actualHeight <= maxH) { stretchFactors.yFactor *= this.conf.player.dimensions.height / actualHeight; } } calculateBasicStretch() { // video.videoWidth in video.videoHeight predstavljata velikost datoteke. // velikost video datoteke je lahko drugačna kot velikost