Fixed cropping via popup

This commit is contained in:
Tamius Han 2019-04-25 22:02:10 +02:00
parent c9f806cd5f
commit d51ce8add7
4 changed files with 34 additions and 41 deletions

View File

@ -8,7 +8,7 @@ var Debug = {
debug: true, debug: true,
// debug: false, // debug: false,
keyboard: true, keyboard: true,
// debugResizer: true, debugResizer: true,
// debugArDetect: true, // debugArDetect: true,
// debugStorage: false, // debugStorage: false,
// debugStorage: true, // debugStorage: true,

View File

@ -75,7 +75,7 @@ class Resizer {
calculateRatioForLegacyOptions(ar){ calculateRatioForLegacyOptions(ar){
// also present as modeToAr in Scaler.js // also present as modeToAr in Scaler.js
if (ar.ratio) { 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". // Skrbi za "stare" možnosti, kot na primer "na širino zaslona", "na višino zaslona" in "ponastavi".
// Približevanje opuščeno. // Približevanje opuščeno.
@ -83,7 +83,7 @@ class Resizer {
var ratioOut; var ratioOut;
if (!this.conf.video) { if (!this.conf.video) {
if(Debug.debug){ if (Debug.debug) {
console.log("[Scaler.js::modeToAr] No video??",this.conf.video, "killing videoData"); console.log("[Scaler.js::modeToAr] No video??",this.conf.video, "killing videoData");
} }
this.conf.destroy(); this.conf.destroy();
@ -91,10 +91,9 @@ class Resizer {
} }
if(! this.conf.player.dimensions ){ if (! this.conf.player.dimensions) {
ratioOut = screen.width / screen.height; ratioOut = screen.width / screen.height;
} } else {
else {
ratioOut = this.conf.player.dimensions.width / this.conf.player.dimensions.height; 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; var fileAr = this.conf.video.videoWidth / this.conf.video.videoHeight;
if (ar.type === AspectRatio.FitWidth){ if (ar.type === AspectRatio.FitWidth){
ratioOut > fileAr ? ratioOut : fileAr ar.ratio = ratioOut > fileAr ? ratioOut : fileAr;
ar.ratio = ratioOut;
return ratioOut;
} }
else if(ar.type === AspectRatio.FitHeight){ else if(ar.type === AspectRatio.FitHeight){
ratioOut < fileAr ? ratioOut : fileAr ar.ratio = ratioOut < fileAr ? ratioOut : fileAr;
ar.ratio = ratioOut;
return ratioOut;
} }
else if(ar.type === AspectRatio.Reset){ else if(ar.type === AspectRatio.Reset){
if(Debug.debug){ 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; ar.ratio = fileAr;
return fileAr; } else {
return null;
} }
return null; return ar;
} }
@ -141,17 +137,19 @@ class Resizer {
return; return;
} }
if(lastAr) { if (lastAr) {
this.lastAr = lastAr; this.lastAr = lastAr;
} else { } else {
if(isNaN(ar)){ // NOTE: "fitw" "fith" and "reset" should ignore ar.ratio bit, but
// NOTE: "fitw" "fith" and "reset" should ignore ar.ratio bit, but // I'm not sure whether they do. Check that.
// I'm not sure whether they do. Check that. ar = this.calculateRatioForLegacyOptions(ar);
this.lastAr = {type: ar.type, ratio: ar.ratio} if (! ar) {
this.calculateRatioForLegacyOptions(ar); if (Debug.debug && Debug.debugResizer) {
} else { console.log(`[Resizer::setAr] <${this.resizerId}> Something wrong with ar or the player. Doing nothing.`);
throw 'Ar was passed as a number rather than an object. You missed one.' }
return;
} }
this.lastAr = {type: ar.type, ratio: ar.ratio}
} }
if (this.extensionMode === ExtensionMode.Basic && !PlayerData.isFullScreen() && ar.type !== AspectRatio.Reset) { if (this.extensionMode === ExtensionMode.Basic && !PlayerData.isFullScreen() && ar.type !== AspectRatio.Reset) {

View File

@ -76,25 +76,19 @@ class Scaler {
return {error: "no_video"}; 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){ if (ar.type === AspectRatio.Reset){
return {xFactor: 1, yFactor: 1} return {xFactor: 1, yFactor: 1}
} }
var ratio = this.modeToAr(ar);
// handle fuckie-wuckies // handle fuckie-wuckies
if (! ratio){ if (! ar.ratio){
if(Debug.debug) if(Debug.debug)
console.log("[Scaler::calculateCrop] no ar?", ratio, " -- we were given this mode:", ar); console.log("[Scaler::calculateCrop] no ar?", ar.ratio, " -- we were given this mode:", ar);
return {error: "no_ar", ratio: ratio}; return {error: "no_ar", ratio: ar.ratio};
} }
if(Debug.debug) 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( (! this.conf.player.dimensions) || this.conf.player.dimensions.width === 0 || this.conf.player.dimensions.height === 0 ){
if(Debug.debug) if(Debug.debug)
@ -110,12 +104,12 @@ class Scaler {
var fileAr = this.conf.video.videoWidth / this.conf.video.videoHeight; var fileAr = this.conf.video.videoWidth / this.conf.video.videoHeight;
var playerAr = this.conf.player.dimensions.width / this.conf.player.dimensions.height; var playerAr = this.conf.player.dimensions.width / this.conf.player.dimensions.height;
if(ar.type == AspectRatio.Initial || !ratio) if(ar.type === AspectRatio.Initial || !ar.ratio)
ratio = fileAr; ar.ratio = fileAr;
if(Debug.debug) 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 = { var videoDimensions = {
xFactor: 1, 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); // 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) // 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) // 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; videoDimensions.yFactor = videoDimensions.xFactor;
} }
else { else {
videoDimensions.xFactor = fileAr / Math.min(ratio, playerAr); videoDimensions.xFactor = fileAr / Math.min(ar.ratio, playerAr);
videoDimensions.yFactor = videoDimensions.xFactor; videoDimensions.yFactor = videoDimensions.xFactor;
} }

View File

@ -21,7 +21,8 @@ class ExecAction {
targetFrame: frame, targetFrame: frame,
frame: frame, frame: frame,
cmd: cmd.action, cmd: cmd.action,
arg: cmd.arg arg: cmd.arg,
customArg: cmd.customArg
} }
Comms.sendMessage(message); Comms.sendMessage(message);
} else if (scope === 'site') { } else if (scope === 'site') {