PlayerData object gets destroyed when videoData does. Scaler now takes video from videoData instead of function arguments

This commit is contained in:
Tamius Han 2018-05-22 00:19:50 +02:00
parent 69d665f6fd
commit a7aef8856d
7 changed files with 38 additions and 8 deletions

View File

@ -11,6 +11,8 @@ Debug = {
// showArDetectCanvas: true,
flushStoredSettings: false,
playerDetectDebug: true,
periodic: true,
videoRescan: true,
arDetect: {
edgeDetect: true
},

View File

@ -47,6 +47,10 @@ class PlayerData {
this.scheduleGhettoWatcher();
}
destroy() {
this.stopChangeDetection();
}
scheduleGhettoWatcher(timeout, force_reset) {
if(! timeout){
timeout = 100;

View File

@ -46,6 +46,9 @@ class VideoData {
if(this.resizer){
this.resizer.destroy();
}
if(this.player){
player.destroy();
}
this.video = null;
}

View File

@ -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;

View File

@ -53,7 +53,8 @@ class DebugCanvas {
}
destroy(){
this.canvas.remove();
if(this.canvas)
this.canvas.remove();
}
setBuffer(buffer) {

View File

@ -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")
}
}
}

View File

@ -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/<video> značke
// Actual aspect ratio of the file/<video> tag
var fileAr = video.videoWidth / video.videoHeight;
var fileAr = this.conf.video.videoWidth / this.conf.video.videoHeight;
var playerAr = playerDimensions.width / playerDimensions.height;
if(mode == "default" || !ar)