diff --git a/src/ext/conf/Debug.js b/src/ext/conf/Debug.js index f9ec873..4fefdee 100644 --- a/src/ext/conf/Debug.js +++ b/src/ext/conf/Debug.js @@ -8,7 +8,7 @@ var Debug = { debug: true, // debug: false, keyboard: true, - // debugResizer: true, + debugResizer: true, // debugArDetect: true, // debugStorage: false, // debugStorage: true, diff --git a/src/ext/lib/video-transform/Resizer.js b/src/ext/lib/video-transform/Resizer.js index f1ca95f..d47550f 100644 --- a/src/ext/lib/video-transform/Resizer.js +++ b/src/ext/lib/video-transform/Resizer.js @@ -75,7 +75,7 @@ class Resizer { calculateRatioForLegacyOptions(ar){ // also present as modeToAr in Scaler.js if (ar.ratio) { - return ar.ratio; + return ar; } // Skrbi za "stare" možnosti, kot na primer "na širino zaslona", "na višino zaslona" in "ponastavi". // Približevanje opuščeno. @@ -83,7 +83,7 @@ class Resizer { var ratioOut; if (!this.conf.video) { - if(Debug.debug){ + if (Debug.debug) { console.log("[Scaler.js::modeToAr] No video??",this.conf.video, "killing videoData"); } this.conf.destroy(); @@ -91,10 +91,9 @@ class Resizer { } - if(! this.conf.player.dimensions ){ + if (! this.conf.player.dimensions) { ratioOut = screen.width / screen.height; - } - else { + } else { ratioOut = this.conf.player.dimensions.width / this.conf.player.dimensions.height; } @@ -107,24 +106,21 @@ class Resizer { var fileAr = this.conf.video.videoWidth / this.conf.video.videoHeight; if (ar.type === AspectRatio.FitWidth){ - ratioOut > fileAr ? ratioOut : fileAr - ar.ratio = ratioOut; - return ratioOut; + ar.ratio = ratioOut > fileAr ? ratioOut : fileAr; } else if(ar.type === AspectRatio.FitHeight){ - ratioOut < fileAr ? ratioOut : fileAr - ar.ratio = ratioOut; - return ratioOut; + ar.ratio = ratioOut < fileAr ? ratioOut : fileAr; } else if(ar.type === AspectRatio.Reset){ if(Debug.debug){ - console.log("[Scaler.js::modeToAr] Using original aspect ratio -", fileAr) + console.log("[Scaler.js::modeToAr] Using original aspect ratio -", fileAr); } - ar.ar = fileAr; - return fileAr; + ar.ratio = fileAr; + } else { + return null; } - return null; + return ar; } @@ -141,17 +137,19 @@ class Resizer { return; } - if(lastAr) { + if (lastAr) { this.lastAr = lastAr; } else { - if(isNaN(ar)){ - // NOTE: "fitw" "fith" and "reset" should ignore ar.ratio bit, but - // I'm not sure whether they do. Check that. - this.lastAr = {type: ar.type, ratio: ar.ratio} - this.calculateRatioForLegacyOptions(ar); - } else { - throw 'Ar was passed as a number rather than an object. You missed one.' + // NOTE: "fitw" "fith" and "reset" should ignore ar.ratio bit, but + // I'm not sure whether they do. Check that. + ar = this.calculateRatioForLegacyOptions(ar); + if (! ar) { + if (Debug.debug && Debug.debugResizer) { + console.log(`[Resizer::setAr] <${this.resizerId}> Something wrong with ar or the player. Doing nothing.`); + } + return; } + this.lastAr = {type: ar.type, ratio: ar.ratio} } if (this.extensionMode === ExtensionMode.Basic && !PlayerData.isFullScreen() && ar.type !== AspectRatio.Reset) { diff --git a/src/ext/lib/video-transform/Scaler.js b/src/ext/lib/video-transform/Scaler.js index cb35be4..1c65c61 100644 --- a/src/ext/lib/video-transform/Scaler.js +++ b/src/ext/lib/video-transform/Scaler.js @@ -76,25 +76,19 @@ class Scaler { return {error: "no_video"}; } - - // če je 'ar' string, potem bomo z njim opravili v legacy wrapperju. Seveda obstaja izjema - // if 'ar' is string, we'll handle that in legacy wrapper, with one exception - if (ar.type === AspectRatio.Reset){ return {xFactor: 1, yFactor: 1} } - var ratio = this.modeToAr(ar); - // handle fuckie-wuckies - if (! ratio){ + if (! ar.ratio){ if(Debug.debug) - console.log("[Scaler::calculateCrop] no ar?", ratio, " -- we were given this mode:", ar); - return {error: "no_ar", ratio: ratio}; + console.log("[Scaler::calculateCrop] no ar?", ar.ratio, " -- we were given this mode:", ar); + return {error: "no_ar", ratio: ar.ratio}; } if(Debug.debug) - console.log("[Scaler::calculateCrop] trying to set ar. args are: ar->",ratio,"; this.conf.player.dimensions->",this.conf.player.dimensions.width, "×", this.conf.player.dimensions.height, "| obj:", this.conf.player.dimensions); + 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); if( (! this.conf.player.dimensions) || this.conf.player.dimensions.width === 0 || this.conf.player.dimensions.height === 0 ){ if(Debug.debug) @@ -110,12 +104,12 @@ class Scaler { var fileAr = this.conf.video.videoWidth / this.conf.video.videoHeight; var playerAr = this.conf.player.dimensions.width / this.conf.player.dimensions.height; - if(ar.type == AspectRatio.Initial || !ratio) - ratio = fileAr; + if(ar.type === AspectRatio.Initial || !ar.ratio) + ar.ratio = fileAr; if(Debug.debug) - console.log("[Scaler::calculateCrop] ar is " ,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); + 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); var videoDimensions = { xFactor: 1, @@ -128,15 +122,15 @@ class Scaler { // console.log("[Scaler::calculateCrop] Player dimensions?", this.conf.player.dimensions.width, "×", this.conf.player.dimensions.height, "| obj:", this.conf.player.dimensions); // } - if( fileAr < ratio ){ + if( fileAr < ar.ratio ){ // 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) - videoDimensions.xFactor = Math.min(ratio, playerAr) / fileAr; + videoDimensions.xFactor = Math.min(ar.ratio, playerAr) / fileAr; videoDimensions.yFactor = videoDimensions.xFactor; } else { - videoDimensions.xFactor = fileAr / Math.min(ratio, playerAr); + videoDimensions.xFactor = fileAr / Math.min(ar.ratio, playerAr); videoDimensions.yFactor = videoDimensions.xFactor; } diff --git a/src/popup/js/ExecAction.js b/src/popup/js/ExecAction.js index 581d5b0..637a0b9 100644 --- a/src/popup/js/ExecAction.js +++ b/src/popup/js/ExecAction.js @@ -21,7 +21,8 @@ class ExecAction { targetFrame: frame, frame: frame, cmd: cmd.action, - arg: cmd.arg + arg: cmd.arg, + customArg: cmd.customArg } Comms.sendMessage(message); } else if (scope === 'site') {