From 4eba239da945159ca8b9550af9416ae019046fee Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Sat, 16 Feb 2019 01:54:41 +0100 Subject: [PATCH] Made extgension remember default stretch mode --- src/ext/conf/Debug.js | 4 ++-- src/ext/lib/ar-detect/ArDetector.js | 6 ++---- src/ext/lib/video-data/VideoData.js | 9 ++++++++- src/ext/lib/video-transform/Resizer.js | 19 ++++++++++++------- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/ext/conf/Debug.js b/src/ext/conf/Debug.js index 81dfb05..2ff5034 100644 --- a/src/ext/conf/Debug.js +++ b/src/ext/conf/Debug.js @@ -5,8 +5,8 @@ const _prod = false; var Debug = { performanceMetrics: true, // should not be affected by debug.debug in order to allow benchmarking of the impact logging in console has init: true, - debug: true, - // debug: false, + // debug: true, + debug: false, // keyboard: true, debugResizer: true, debugArDetect: true, diff --git a/src/ext/lib/ar-detect/ArDetector.js b/src/ext/lib/ar-detect/ArDetector.js index 15a112c..8984bde 100644 --- a/src/ext/lib/ar-detect/ArDetector.js +++ b/src/ext/lib/ar-detect/ArDetector.js @@ -18,7 +18,6 @@ class ArDetector { this.sampleCols = []; - // todo: dynamically detect the following two this.canFallback = true; this.fallbackMode = false; @@ -60,7 +59,7 @@ class ArDetector { throw "Settings prevent autoar from starting" } } catch (e) { - console.log("[ArDetect::init] INITIALIZATION FAILED!\n", e); + console.log("%c[ArDetect::init] INITIALIZATION FAILED!\n", _ard_console_stop, e); } } @@ -72,7 +71,7 @@ class ArDetector { this.stop(); } - setup(cwidth, cheight, forceStart){ + setup(cwidth, cheight){ if(Debug.debug || Debug.init) { console.log("[ArDetect::setup] Starting autodetection setup. arid:", this.arid); } @@ -237,7 +236,6 @@ class ArDetector { // (we are running when _halted is neither true nor undefined) if (this._halted === false) { this._paused = true; - // this.conf.resizer.resetLastAr(); } } diff --git a/src/ext/lib/video-data/VideoData.js b/src/ext/lib/video-data/VideoData.js index ccb3088..ff649a0 100644 --- a/src/ext/lib/video-data/VideoData.js +++ b/src/ext/lib/video-data/VideoData.js @@ -22,6 +22,13 @@ class VideoData { this.arDetector = new ArDetector(this); // this starts Ar detection. needs optional parameter that prevets ardetdctor from starting // player dimensions need to be in: // this.player.dimensions + + // apply default align and stretch + if (Debug.init) { + console.log("%c[VideoData::ctor] Initial resizer reset!", {background: '#afd', color: '#132'}); + } + this.resizer.reset(); + this.vdid = (Math.random()*100).toFixed(); if (Debug.init) { @@ -144,7 +151,7 @@ class VideoData { this.arDetector.setManualTick(manualTick); } } - + tick() { if(this.arDetector){ this.arDetector.tick(); diff --git a/src/ext/lib/video-transform/Resizer.js b/src/ext/lib/video-transform/Resizer.js index 13b81fd..22d4e35 100644 --- a/src/ext/lib/video-transform/Resizer.js +++ b/src/ext/lib/video-transform/Resizer.js @@ -37,7 +37,8 @@ class Resizer { this.cssWatcherIncreasedFrequencyCounter = 0; - this.lastAr = this.settings.getDefaultAr(); // this is the aspect ratio we start with + // this.lastAr = this.settings.getDefaultAr(); // this is the aspect ratio we start with + this.lastAr = {type: 'original'}; this.videoAlignment = this.settings.getDefaultVideoAlignment(); // this is initial video alignment this.destroyed = false; @@ -107,12 +108,16 @@ class Resizer { // // pause AR on basic stretch, unpause when using other mdoes // fir sine reason unpause doesn't unpause. investigate that later - if (this.stretcher.mode === StretchMode.Basic) { - this.conf.arDetector.pause(); - } else { - if (this.lastAr.type === 'auto') { - this.conf.arDetector.unpause(); + try { + if (this.stretcher.mode === StretchMode.Basic) { + this.conf.arDetector.pause(); + } else { + if (this.lastAr.type === 'auto') { + this.conf.arDetector.unpause(); + } } + } catch (e) { // resizer starts before arDetector. this will do nothing but fail if arDetector isn't setup + } // do stretch thingy @@ -294,7 +299,7 @@ class Resizer { } reset(){ - this.setStretchMode(StretchMode.NoStretch); + this.setStretchMode(this.settings.active.sites[window.location.hostname] ? this.settings.active.sites[window.location.hostname].stretch : this.settings.active.sites['@global'].stretch); this.zoom.setZoom(1); this.resetPan(); this.setAr('reset');