fixed issue with video alignment not working

This commit is contained in:
Tamius Han 2018-07-15 16:22:32 +02:00
parent 8579d25d5f
commit 6c458d7590
7 changed files with 42 additions and 22 deletions

View File

@ -20,8 +20,11 @@ class CommsClient {
console.log("[CommsClient.js::processMessage] Received message from background script!", message);
}
if(message.cmd === "set-ar"){
if (message.cmd === "set-ar") {
this.pageInfo.setAr(message.ratio);
} else if (message.cmd === 'set-video-float') {
ExtensionConf.miscFullscreenSettings.videoFloat = message.newFloat;
this.pageInfo.restoreAr();
} else if (message.cmd === "has-videos") {
} else if (message.cmd === "set-config") {
@ -239,6 +242,12 @@ class CommsServer {
ExtensionConf.keyboard.shortcuts.q.arg = message.ratio;
Settings.save(ExtensionConf);
this.sendToAll({cmd: 'reload-settings', newConf: ExtensionConf});
} else if (message.cmd === 'set-video-float') {
this.sendToActive(message);
ExtensionConf.miscFullscreenSettings.videoFloat = message.newFloat;
Settings.save(ExtensionConf);
this.sendToAll({cmd: 'reload-settings', newConf: ExtensionConf});
} else if (message.cmd === 'autoar-start') {
this.sendToActive(message);
} else if (message.cmd === "autoar-enable") { // LEGACY - can be removed prolly?

View File

@ -90,7 +90,7 @@ class GuardLine {
// should succeed by default. Also need to check bottom, for cases where only one edge is known
if(! fallbackMode && (! this.blackbar.top || ! this.blackbar.bottom)) {
console.log("NO EDGE WAS DETECTED. THIS TEST IS POINTLESS. btw guardline")
// console.log("NO EDGE WAS DETECTED. THIS TEST IS POINTLESS. btw guardline")
return { success: true };
}

View File

@ -95,6 +95,10 @@ class VideoData {
this.resizer.setAr(ar, lastAr);
}
restoreAr(){
this.resizer.restore();
}
setStretchMode(stretchMode){
this.resizer.setStretchMode(stretchMode);
}

View File

@ -348,7 +348,9 @@ class ArDetector {
if(this.fallbackMode){
if(edges.top > 1 && edges.top <= ExtensionConf.arDetect.fallbackMode.noTriggerZonePx ){
console.log("Edge is in the no-trigger zone. Aspect ratio change is not triggered.")
if(Debug.debug && Debug.debugArDetect) {
console.log("Edge is in the no-trigger zone. Aspect ratio change is not triggered.")
}
return;
}
@ -450,9 +452,10 @@ class ArDetector {
this.context.drawImage(this.video, 0,0, this.canvas.width, this.canvas.height);
}
catch(ex){
if(Debug.debug)
if(Debug.debug) {
console.log("%c[ArDetect::_ard_vdraw] can't draw image on canvas. Trying canvas.drawWindow instead", "color:#000; backgroud:#f51;", ex);
}
try{
if(! ExtensionConf.arDetect.fallbackMode.enabled)
throw "fallbackMode is disabled.";

View File

@ -215,6 +215,12 @@ class PageInfo {
}
}
restoreAr() {
for(var vd of this.videos){
vd.restoreAr()
}
}
setStretchMode(sm){
// TODO: find a way to only change aspect ratio for one video

View File

@ -67,11 +67,12 @@ class Resizer {
}
// pause AR on basic stretch, unpause when using other mdoes
if (this.stretcher.mode === StretchMode.BASIC) {
this.conf.arDetector.pause();
} else {
this.conf.arDetector.unpause();
}
// fir sine reason unpause doesn't unpause. investigate that later
// if (this.stretcher.mode === StretchMode.BASIC) {
// this.conf.arDetector.pause();
// } else {
// this.conf.arDetector.unpause();
// }
// do stretch thingy
if (this.stretcher.mode === StretchMode.NO_STRETCH || this.stretcher.mode === StretchMode.CONDITIONAL){
@ -205,14 +206,14 @@ class Resizer {
var translate = {x: 0, y: 0};
if(this.pan){
if (this.pan) {
// todo: calculate translate
} else {
if( ExtensionConf.miscFullscreenSettings.videoFloat == "left" ){
translate.x = (this.conf.player.dimensions.width - actualWidth ) * -0.5;
if (ExtensionConf.miscFullscreenSettings.videoFloat == "left") {
translate.x = (this.conf.player.dimensions.width - actualWidth) * -0.5;
}
else if( ExtensionConf.miscFullscreenSettings.videoFloat == "right" ){
translate.x = (this.conf.player.dimensions.width - actualWidth ) * 0.5;
else if (ExtensionConf.miscFullscreenSettings.videoFloat == "right") {
translate.x = (this.conf.player.dimensions.width - actualWidth) * 0.5;
}
}
@ -221,7 +222,7 @@ class Resizer {
applyCss(stretchFactors, translate){
if (! this.video ){
if (! this.video) {
if(Debug.debug)
console.log("[Resizer::_res_applyCss] Video went missing, doing nothing.");
this.conf.destroy();
@ -266,9 +267,6 @@ class Resizer {
styleString += styleArray[i] + "; ";
this.setStyleString(styleString);
}
setStyleString (styleString, count = 0) {

View File

@ -587,7 +587,7 @@ document.addEventListener("click", (e) => {
command.global = true;
if(e.target.classList.contains("_align_left")){
command.cmd = "force-video-float",
command.cmd = "set-video-float",
command.newFloat = "left"
// console.log(".................\n\n\n..........\n\n >>command<< \n\n\n\n ",command,"\n\n\n.........\n\n\n................................");
@ -595,12 +595,12 @@ document.addEventListener("click", (e) => {
return command;
}
if(e.target.classList.contains("_align_center")){
command.cmd = "force-video-float"
command.cmd = "set-video-float"
command.newFloat = "center"
return command;
}
if(e.target.classList.contains("_align_right")){
command.cmd = "force-video-float";
command.cmd = "set-video-float";
command.newFloat = "right";
return command;
}