Basic mode works when switching to full screen (on clips.twitch)
doesn't work when we go back from the full screen mode tho
This commit is contained in:
parent
94990a0ba8
commit
985e285914
@ -33,11 +33,13 @@ class PlayerData {
|
||||
this.videoData = videoData;
|
||||
this.video = videoData.video;
|
||||
this.settings = videoData.settings;
|
||||
this.extensionMode = videoData.extensionMode;
|
||||
this.element = undefined;
|
||||
this.dimensions = undefined;
|
||||
|
||||
|
||||
this.getPlayerDimensions();
|
||||
if (this.extensionMode === ExtensionMode.Full) {
|
||||
this.getPlayerDimensions();
|
||||
}
|
||||
this.startChangeDetection();
|
||||
}
|
||||
|
||||
@ -102,8 +104,7 @@ class PlayerData {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
ghettoWatcher(){
|
||||
ghettoWatcherFull() {
|
||||
if(this.checkPlayerSizeChange()){
|
||||
if(Debug.debug){
|
||||
console.log("[uw::ghettoOnChange] change detected");
|
||||
@ -111,13 +112,10 @@ class PlayerData {
|
||||
|
||||
this.getPlayerDimensions();
|
||||
if(! this.element ){
|
||||
this.scheduleGhettoWatcher();
|
||||
return;
|
||||
}
|
||||
|
||||
this.videoData.resizer.restore(); // note: this returns true if change goes through, false otherwise.
|
||||
|
||||
this.scheduleGhettoWatcher();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -134,17 +132,44 @@ class PlayerData {
|
||||
this.getPlayerDimensions();
|
||||
|
||||
if(! this.element ){
|
||||
this.scheduleGhettoWatcher();
|
||||
return;
|
||||
}
|
||||
|
||||
this.videoData.resizer.restore();
|
||||
}
|
||||
}
|
||||
|
||||
ghettoWatcherBasic() {
|
||||
if (this.checkFullscreenChange()) {
|
||||
if (PlayerData.isFullScreen()) {
|
||||
this.videoData.resizer.restore();
|
||||
this.videoData.startArDetection();
|
||||
} else {
|
||||
const lastAr = this.videoData.resizer.getLastAr(); // save last ar for restore later
|
||||
this.videoData.resizer.reset();
|
||||
this.videoData.resizer.stop();
|
||||
this.videoData.resizer.setLastAr(lastAr);
|
||||
this.videoData.stopArDetection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ghettoWatcher(){
|
||||
if (this.extensionMode === ExtensionMode.Full) {
|
||||
this.ghettoWatcherFull();
|
||||
this.scheduleGhettoWatcher();
|
||||
} else if (this.extensionMode === ExtensionMode.Basic) {
|
||||
console.log("ghetto watcher basic mode - triggered")
|
||||
this.ghettoWatcherBasic();
|
||||
this.scheduleGhettoWatcher();
|
||||
}
|
||||
|
||||
this.scheduleGhettoWatcher();
|
||||
}
|
||||
|
||||
panHandler(event) {
|
||||
if (this.extensionMode !== ExtensionMode.Full) {
|
||||
return;
|
||||
}
|
||||
this.videoData.panHandler(event);
|
||||
}
|
||||
|
||||
@ -280,5 +305,35 @@ class PlayerData {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
checkFullscreenChange() {
|
||||
const isFs = PlayerData.isFullScreen();
|
||||
|
||||
console.log("isFs:", isFs)
|
||||
|
||||
if (this.dimensions) {
|
||||
if (this.dimensions.fullscreen != isFs) {
|
||||
this.dimensions = {
|
||||
fullscreen: isFs,
|
||||
width: screen.width,
|
||||
height: screen.height
|
||||
};
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if(Debug.debug) {
|
||||
console.log("[PlayerData::checkFullscreenChange] this.dimensions is not defined.")
|
||||
}
|
||||
|
||||
this.dimensions = {
|
||||
fullscreen: isFs,
|
||||
width: screen.width,
|
||||
height: screen.height
|
||||
};
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,3 @@
|
||||
var ExtensionMode = Object.freeze(
|
||||
{
|
||||
AutoDisabled: -2,
|
||||
Disabled: -1,
|
||||
Default: 0,
|
||||
Basic: 1,
|
||||
Full: 2
|
||||
}
|
||||
);
|
||||
|
||||
class Settings {
|
||||
|
||||
constructor(activeSettings, updateCallback) {
|
||||
|
@ -8,12 +8,10 @@ class VideoData {
|
||||
this.pageInfo = pageInfo;
|
||||
this.extensionMode = pageInfo.extensionMode;
|
||||
|
||||
|
||||
|
||||
// POZOR: VRSTNI RED JE POMEMBEN (arDetect mora bit zadnji)
|
||||
// NOTE: ORDERING OF OBJ INITIALIZATIONS IS IMPORTANT (arDetect needs to go last)
|
||||
if (pageInfo.extensionMode === ExtensionMode.Full) {
|
||||
this.player = new PlayerData(this);
|
||||
}
|
||||
this.player = new PlayerData(this);
|
||||
this.resizer = new Resizer(this);
|
||||
|
||||
this.arDetector = new ArDetector(this); // this starts Ar detection. needs optional parameter that prevets ardetdctor from starting
|
||||
@ -22,7 +20,7 @@ class VideoData {
|
||||
|
||||
this.vdid = (Math.random()*100).toFixed();
|
||||
if (Debug.init) {
|
||||
console.log("[VideoData::ctor] Created videoData with vdid", this.vdid);
|
||||
console.log("[VideoData::ctor] Created videoData with vdid", this.vdid,"\nextension mode:", this.extensionMode);
|
||||
}
|
||||
}
|
||||
|
||||
|
14
js/lib/enums.js
Normal file
14
js/lib/enums.js
Normal file
@ -0,0 +1,14 @@
|
||||
var ExtensionMode = Object.freeze({
|
||||
AutoDisabled: -2,
|
||||
Disabled: -1,
|
||||
Default: 0,
|
||||
Basic: 1,
|
||||
Full: 2
|
||||
});
|
||||
|
||||
var StretchMode = Object.freeze({
|
||||
NO_STRETCH: 0,
|
||||
BASIC: 1,
|
||||
HYBRID: 2,
|
||||
CONDITIONAL: 3
|
||||
});
|
@ -1,19 +1,13 @@
|
||||
if(Debug.debug)
|
||||
console.log("Loading: Resizer.js");
|
||||
|
||||
var StretchMode = {
|
||||
NO_STRETCH: 0,
|
||||
BASIC: 1,
|
||||
HYBRID: 2,
|
||||
CONDITIONAL: 3
|
||||
}
|
||||
|
||||
class Resizer {
|
||||
class Resizer {
|
||||
|
||||
constructor(videoData){
|
||||
constructor(videoData) {
|
||||
this.conf = videoData;
|
||||
this.video = videoData.video;
|
||||
this.settings = videoData.settings;
|
||||
this.extensionMode = videoData.extensionMode;
|
||||
|
||||
this.scaler = new Scaler(this.conf);
|
||||
this.stretcher = new Stretcher(this.conf);
|
||||
@ -71,9 +65,9 @@ class Resizer {
|
||||
if (this.destroyed) {
|
||||
return;
|
||||
}
|
||||
this.startCssWatcher();
|
||||
this.cssWatcherIncreasedFrequencyCounter = 20;
|
||||
|
||||
|
||||
console.log("ext mode?", this.extensionMode, "basic/full:", ExtensionMode.Basic, ExtensionMode.Full, "is fullscreen?", PlayerData.isFullScreen())
|
||||
|
||||
if(Debug.debug){
|
||||
console.log('[Resizer::setAr] <rid:'+this.resizerId+'> trying to set ar. New ar:', ar)
|
||||
}
|
||||
@ -88,11 +82,20 @@ class Resizer {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.extensionMode !== ExtensionMode.Full && !PlayerData.isFullScreen()) {
|
||||
return; // don't actually apply or calculate css when using basic mode if not in fullscreen
|
||||
}
|
||||
|
||||
if (! this.video) {
|
||||
// console.log("No video detected.")
|
||||
this.videoData.destroy();
|
||||
}
|
||||
|
||||
if (this.extensionMode !== ExtensionMode.Full || PlayerData.isFullScreen()) {
|
||||
this.startCssWatcher();
|
||||
}
|
||||
this.cssWatcherIncreasedFrequencyCounter = 20;
|
||||
|
||||
// // 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) {
|
||||
@ -205,7 +208,7 @@ class Resizer {
|
||||
}
|
||||
|
||||
scheduleCssWatcher(timeout, force_reset) {
|
||||
if (this.destroyed) {
|
||||
if (this.destroyed || (this.extensionMode !== ExtensionMode.Full && !PlayerData.isFullScreen())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
8
js/uw.js
8
js/uw.js
@ -51,7 +51,11 @@ class UW {
|
||||
// če smo razširitev onemogočili v nastavitvah, ne naredimo ničesar
|
||||
// If extension is soft-disabled, don't do shit
|
||||
|
||||
extensionMode = this.settings.getExtensionMode();
|
||||
var extensionMode = this.settings.getExtensionMode();
|
||||
|
||||
if(Debug.debug) {
|
||||
console.log("[uw::init] Extension mode:" + (extensionMode < 0 ? "disabled" : extensionMode == '1' ? 'basic' : 'full'));
|
||||
}
|
||||
|
||||
if(extensionMode === ExtensionMode.Disabled){
|
||||
if(Debug.debug) {
|
||||
@ -61,7 +65,7 @@ class UW {
|
||||
}
|
||||
|
||||
try {
|
||||
this.pageInfo = new PageInfo(this.comms, this.settings);
|
||||
this.pageInfo = new PageInfo(this.comms, this.settings, extensionMode);
|
||||
if(Debug.debug){
|
||||
console.log("[uw.js::setup] pageInfo initialized. Here's the object:", this.pageInfo);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"manifest_version": 2,
|
||||
"name": "Ultrawidify",
|
||||
"version": "3.2.2",
|
||||
"version": "3.2.3-a1",
|
||||
"applications": {
|
||||
"gecko": {
|
||||
"id": "{cf02b1a7-a01a-4e37-a609-516a283f1ed3}"
|
||||
@ -19,6 +19,7 @@
|
||||
"matches": ["*://*/*"],
|
||||
"js": [
|
||||
"js/conf/Debug.js",
|
||||
"js/lib/enums.js",
|
||||
|
||||
"js/lib/BrowserDetect.js",
|
||||
"js/conf/ExtensionConf.js",
|
||||
|
Loading…
Reference in New Issue
Block a user