diff --git a/js/conf/Debug.js b/js/conf/Debug.js index 7dd594b..45ff6fe 100644 --- a/js/conf/Debug.js +++ b/js/conf/Debug.js @@ -11,6 +11,8 @@ Debug = { // showArDetectCanvas: true, flushStoredSettings: false, playerDetectDebug: true, + periodic: true, + videoRescan: true, arDetect: { edgeDetect: true }, diff --git a/js/lib/PlayerData.js b/js/lib/PlayerData.js index ce471d2..5d7c428 100644 --- a/js/lib/PlayerData.js +++ b/js/lib/PlayerData.js @@ -47,6 +47,10 @@ class PlayerData { this.scheduleGhettoWatcher(); } + destroy() { + this.stopChangeDetection(); + } + scheduleGhettoWatcher(timeout, force_reset) { if(! timeout){ timeout = 100; diff --git a/js/lib/VideoData.js b/js/lib/VideoData.js index 44ad642..ec39db5 100644 --- a/js/lib/VideoData.js +++ b/js/lib/VideoData.js @@ -46,6 +46,9 @@ class VideoData { if(this.resizer){ this.resizer.destroy(); } + if(this.player){ + player.destroy(); + } this.video = null; } diff --git a/js/modules/ArDetect.js b/js/modules/ArDetect.js index ebd4d98..8ff2c09 100644 --- a/js/modules/ArDetect.js +++ b/js/modules/ArDetect.js @@ -45,8 +45,7 @@ class ArDetector { try{ if(Debug.debug){ - console.log("%c[ArDetect::setup] Starting automatic aspect ratio detection.", _ard_console_start); - console.log("[ArDetect::setup] Choice config bits:\ncanvas dimensions:",cwidth, "×", cheight, "\nvideoData:", this.conf); + console.log("[ArDetect::setup] Trying to setup automatic aspect ratio detector. Choice config bits:\ncanvas dimensions:",cwidth, "×", cheight, "\nvideoData:", this.conf); } this._halted = false; @@ -157,6 +156,7 @@ class ArDetector { } start(){ + console.log("%c[ArDetect::setup] Starting automatic aspect ratio detection.", _ard_console_start); this._halted = false; this.scheduleFrameCheck(0, true); } @@ -212,6 +212,13 @@ class ArDetector { var ths = this; + // console.log(this.video, "this.video | ths.video", ths.video) + // console.log(this.conf.video, "this.conf | ths.conf", ths.conf.video) + // console.log("resizer conf&vid", + // this.conf.resizer, this.conf.resizer.conf, this.conf.resizer.video, this.conf.resizer.conf.video ) + + // debugger; + this.timer = setTimeout(function(){ ths.timer = null; try{ @@ -361,6 +368,10 @@ class ArDetector { } frameCheck(){ + + // console.log("this.video:", this.video, this.conf.video); + // debugger; + if(this._halted) return; diff --git a/js/modules/DebugCanvas.js b/js/modules/DebugCanvas.js index 85e3abf..8e611a0 100644 --- a/js/modules/DebugCanvas.js +++ b/js/modules/DebugCanvas.js @@ -53,7 +53,8 @@ class DebugCanvas { } destroy(){ - this.canvas.remove(); + if(this.canvas) + this.canvas.remove(); } setBuffer(buffer) { diff --git a/js/modules/PageInfo.js b/js/modules/PageInfo.js index 2309ddf..044115f 100644 --- a/js/modules/PageInfo.js +++ b/js/modules/PageInfo.js @@ -59,9 +59,18 @@ class PageInfo { if (videoExists) { continue; } else { + if(Debug.debug && Debug.periodic && Debug.videoRescan){ + console.log("[PageInfo::rescan] found new video candidate:", video) + } v = new VideoData(video); + // console.log("[PageInfo::rescan] v is:", v) + // debugger; v.initArDetection(); this.videos.push(v); + + if(Debug.debug && Debug.periodic && Debug.videoRescan){ + console.log("[PageInfo::rescan] — videos[] is now this:", this.videos,"\n\n\n\n\n\n\n\n") + } } } diff --git a/js/modules/Scaler.js b/js/modules/Scaler.js index 0e41ed2..978e1bd 100644 --- a/js/modules/Scaler.js +++ b/js/modules/Scaler.js @@ -16,9 +16,9 @@ class Scaler { // handles "legacy" options, such as 'fit to widht', 'fit to height' and 'reset'. No zoom tho var ar; - if (!video) { + if (!this.conf.video) { if(Debug.debug){ - console.log("[Scaler.js::modeToAr] No video??",video, "killing videoData"); + console.log("[Scaler.js::modeToAr] No video??",this.conf.video, "killing videoData"); } this.conf.destroy(); return null; @@ -38,7 +38,7 @@ class Scaler { // IMPORTANT NOTE: GlobalVars.lastAr needs to be set after _res_setAr() is called, as _res_setAr() assumes we're // setting a static aspect ratio (even if the function is called from here or ArDetect). - var fileAr = video.videoWidth / video.videoHeight; + var fileAr = this.conf.video.videoWidth / this.conf.video.videoHeight; if (mode == "fitw"){ return ar > fileAr ? ar : fileAr; @@ -60,7 +60,7 @@ class Scaler { calculateCrop(mode, video, playerDimensions) { - if(!video || video.videoWidth == 0 || video.videoHeight == 0){ + if(!this.conf.video || this.conf.video.videoWidth == 0 || this.conf.video.videoHeight == 0){ if(Debug.debug) console.log("[Scaler::calculateCrop] ERROR — no video detected."); @@ -99,7 +99,7 @@ class Scaler { // Dejansko razmerje stranic datoteke/