PlayerData object gets destroyed when videoData does. Scaler now takes video from videoData instead of function arguments
This commit is contained in:
parent
69d665f6fd
commit
a7aef8856d
@ -11,6 +11,8 @@ Debug = {
|
|||||||
// showArDetectCanvas: true,
|
// showArDetectCanvas: true,
|
||||||
flushStoredSettings: false,
|
flushStoredSettings: false,
|
||||||
playerDetectDebug: true,
|
playerDetectDebug: true,
|
||||||
|
periodic: true,
|
||||||
|
videoRescan: true,
|
||||||
arDetect: {
|
arDetect: {
|
||||||
edgeDetect: true
|
edgeDetect: true
|
||||||
},
|
},
|
||||||
|
@ -47,6 +47,10 @@ class PlayerData {
|
|||||||
this.scheduleGhettoWatcher();
|
this.scheduleGhettoWatcher();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
destroy() {
|
||||||
|
this.stopChangeDetection();
|
||||||
|
}
|
||||||
|
|
||||||
scheduleGhettoWatcher(timeout, force_reset) {
|
scheduleGhettoWatcher(timeout, force_reset) {
|
||||||
if(! timeout){
|
if(! timeout){
|
||||||
timeout = 100;
|
timeout = 100;
|
||||||
|
@ -46,6 +46,9 @@ class VideoData {
|
|||||||
if(this.resizer){
|
if(this.resizer){
|
||||||
this.resizer.destroy();
|
this.resizer.destroy();
|
||||||
}
|
}
|
||||||
|
if(this.player){
|
||||||
|
player.destroy();
|
||||||
|
}
|
||||||
this.video = null;
|
this.video = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,8 +45,7 @@ class ArDetector {
|
|||||||
|
|
||||||
try{
|
try{
|
||||||
if(Debug.debug){
|
if(Debug.debug){
|
||||||
console.log("%c[ArDetect::setup] Starting automatic aspect ratio detection.", _ard_console_start);
|
console.log("[ArDetect::setup] Trying to setup automatic aspect ratio detector. Choice config bits:\ncanvas dimensions:",cwidth, "×", cheight, "\nvideoData:", this.conf);
|
||||||
console.log("[ArDetect::setup] Choice config bits:\ncanvas dimensions:",cwidth, "×", cheight, "\nvideoData:", this.conf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this._halted = false;
|
this._halted = false;
|
||||||
@ -157,6 +156,7 @@ class ArDetector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
start(){
|
start(){
|
||||||
|
console.log("%c[ArDetect::setup] Starting automatic aspect ratio detection.", _ard_console_start);
|
||||||
this._halted = false;
|
this._halted = false;
|
||||||
this.scheduleFrameCheck(0, true);
|
this.scheduleFrameCheck(0, true);
|
||||||
}
|
}
|
||||||
@ -212,6 +212,13 @@ class ArDetector {
|
|||||||
|
|
||||||
var ths = this;
|
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(){
|
this.timer = setTimeout(function(){
|
||||||
ths.timer = null;
|
ths.timer = null;
|
||||||
try{
|
try{
|
||||||
@ -361,6 +368,10 @@ class ArDetector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
frameCheck(){
|
frameCheck(){
|
||||||
|
|
||||||
|
// console.log("this.video:", this.video, this.conf.video);
|
||||||
|
// debugger;
|
||||||
|
|
||||||
if(this._halted)
|
if(this._halted)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -53,7 +53,8 @@ class DebugCanvas {
|
|||||||
}
|
}
|
||||||
|
|
||||||
destroy(){
|
destroy(){
|
||||||
this.canvas.remove();
|
if(this.canvas)
|
||||||
|
this.canvas.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
setBuffer(buffer) {
|
setBuffer(buffer) {
|
||||||
|
@ -59,9 +59,18 @@ class PageInfo {
|
|||||||
if (videoExists) {
|
if (videoExists) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
if(Debug.debug && Debug.periodic && Debug.videoRescan){
|
||||||
|
console.log("[PageInfo::rescan] found new video candidate:", video)
|
||||||
|
}
|
||||||
v = new VideoData(video);
|
v = new VideoData(video);
|
||||||
|
// console.log("[PageInfo::rescan] v is:", v)
|
||||||
|
// debugger;
|
||||||
v.initArDetection();
|
v.initArDetection();
|
||||||
this.videos.push(v);
|
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")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,9 +16,9 @@ class Scaler {
|
|||||||
// handles "legacy" options, such as 'fit to widht', 'fit to height' and 'reset'. No zoom tho
|
// handles "legacy" options, such as 'fit to widht', 'fit to height' and 'reset'. No zoom tho
|
||||||
var ar;
|
var ar;
|
||||||
|
|
||||||
if (!video) {
|
if (!this.conf.video) {
|
||||||
if(Debug.debug){
|
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();
|
this.conf.destroy();
|
||||||
return null;
|
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
|
// 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).
|
// 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"){
|
if (mode == "fitw"){
|
||||||
return ar > fileAr ? ar : fileAr;
|
return ar > fileAr ? ar : fileAr;
|
||||||
@ -60,7 +60,7 @@ class Scaler {
|
|||||||
calculateCrop(mode, video, playerDimensions) {
|
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)
|
if(Debug.debug)
|
||||||
console.log("[Scaler::calculateCrop] ERROR — no video detected.");
|
console.log("[Scaler::calculateCrop] ERROR — no video detected.");
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ class Scaler {
|
|||||||
|
|
||||||
// Dejansko razmerje stranic datoteke/<video> značke
|
// Dejansko razmerje stranic datoteke/<video> značke
|
||||||
// Actual aspect ratio of the file/<video> tag
|
// 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;
|
var playerAr = playerDimensions.width / playerDimensions.height;
|
||||||
|
|
||||||
if(mode == "default" || !ar)
|
if(mode == "default" || !ar)
|
||||||
|
Loading…
Reference in New Issue
Block a user