diff --git a/src/ext/lib/video-data/PlayerData.ts b/src/ext/lib/video-data/PlayerData.ts index bd34ae1..11e2fcb 100644 --- a/src/ext/lib/video-data/PlayerData.ts +++ b/src/ext/lib/video-data/PlayerData.ts @@ -63,7 +63,7 @@ class PlayerData { //#region misc stuff extensionMode: any; - dimensions: any; + dimensions: {width?: number, height?: number, fullscreen?: boolean}; private playerIdElement: any; private observer: ResizeObserver; //#endregion diff --git a/src/ext/lib/video-transform/Scaler.ts b/src/ext/lib/video-transform/Scaler.ts index ecb65cf..5387235 100644 --- a/src/ext/lib/video-transform/Scaler.ts +++ b/src/ext/lib/video-transform/Scaler.ts @@ -5,6 +5,31 @@ import VideoData from '../video-data/VideoData'; import Logger from '../Logger'; +export enum CropStrategy { + /** + * Nomenclature explained: + * + * SP - stream AR < player AR + * PS - the opposite of ↑ + * + * ArDominant - given aspect ratio is bigger than stream AR and player AR + * PSDominant - stream AR or player AR are bigger than given aspect ratio + */ + CropLetterbox = 1, + NoCropPillarbox = 2, + NoCropLetterbox = 3, + CropPillarbox = 4 +} + +export type VideoDimensions = { + xFactor?: number; + yFactor?: number; + cropStrategy?: number; + arCorrectionFactor?: number; + actualWidth?: number; + actualHeight?: number; +} + // računa velikost videa za približevanje/oddaljevanje // does video size calculations for zooming/cropping @@ -72,7 +97,7 @@ class Scaler { return null; } - calculateCrop(ar) { + calculateCrop(ar: {type: AspectRatioType, ratio?: number}) { /** * STEP 1: NORMALIZE ASPECT RATIO * @@ -151,7 +176,7 @@ class Scaler { this.logger.log('info', 'scaler', "[Scaler::calculateCrop] ar is " ,ar.ratio, ", file ar is", streamAr, ", this.conf.player.dimensions are ", this.conf.player.dimensions.width, "×", this.conf.player.dimensions.height, "| obj:", this.conf.player.dimensions); - const videoDimensions = { + const videoDimensions: VideoDimensions = { xFactor: 1, yFactor: 1, actualWidth: 0, // width of the video (excluding pillarbox) when