Force player re-detection when setting aspect ratio
This commit is contained in:
parent
5a6195d36d
commit
289baf73e5
@ -241,6 +241,17 @@ const ExtensionConfPatch = [
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
forVersion: '4.4.1.1',
|
||||||
|
sites: {
|
||||||
|
"www.disneyplus.com": {
|
||||||
|
DOM: {
|
||||||
|
player: {
|
||||||
|
periodicallyRefreshPlayerElement: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -1083,6 +1083,13 @@ whatsNewChecked: true,
|
|||||||
},
|
},
|
||||||
css: 'video {\n width: 100% !important;\n height: 100% !important;\n}',
|
css: 'video {\n width: 100% !important;\n height: 100% !important;\n}',
|
||||||
},
|
},
|
||||||
|
"www.disneyplus.com": {
|
||||||
|
DOM: {
|
||||||
|
player: {
|
||||||
|
periodicallyRefreshPlayerElement: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"imgur.com": {
|
"imgur.com": {
|
||||||
mode: -1,
|
mode: -1,
|
||||||
autoar: -1,
|
autoar: -1,
|
||||||
|
@ -45,6 +45,13 @@ class PlayerData {
|
|||||||
this.dimensions = undefined;
|
this.dimensions = undefined;
|
||||||
this.overlayNode = undefined;
|
this.overlayNode = undefined;
|
||||||
|
|
||||||
|
this.periodicallyRefreshPlayerElement = false;
|
||||||
|
try {
|
||||||
|
this.periodicallyRefreshPlayerElement = this.settings.active.sites[window.location.host].DOM.player.periodicallyRefreshPlayerElement;
|
||||||
|
} catch (e) {
|
||||||
|
// no biggie — that means we don't have any special settings for this site.
|
||||||
|
}
|
||||||
|
|
||||||
// this happens when we don't find a matching player element
|
// this happens when we don't find a matching player element
|
||||||
if (!this.element) {
|
if (!this.element) {
|
||||||
this.invalid = true;
|
this.invalid = true;
|
||||||
@ -98,19 +105,19 @@ class PlayerData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const ths = this;
|
const ths = this;
|
||||||
this.observer = new MutationObserver((m,o) => this.onPlayerDimensionsChanged(m,o,ths));
|
this.observer = new MutationObserver((m,o) => this.onPlayerDimensionsChanged(m,o,ths));
|
||||||
|
|
||||||
const observerConf = {
|
const observerConf = {
|
||||||
attributes: true,
|
attributes: true,
|
||||||
// attributeFilter: ['style', 'class'],
|
// attributeFilter: ['style', 'class'],
|
||||||
attributeOldValue: true,
|
attributeOldValue: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.observer.observe(this.element, observerConf);
|
this.observer.observe(this.element, observerConf);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("failed to set observer",e )
|
console.error("failed to set observer",e )
|
||||||
}
|
}
|
||||||
// legacy mode still exists, but acts as a fallback for observers and is triggered less
|
// legacy mode still exists, but acts as a fallback for observers and is triggered less
|
||||||
// frequently in order to avoid too many pointless checks
|
// frequently in order to avoid too many pointless checks
|
||||||
this.legacyChangeDetection();
|
this.legacyChangeDetection();
|
||||||
@ -120,6 +127,9 @@ class PlayerData {
|
|||||||
while (!this.halted) {
|
while (!this.halted) {
|
||||||
await this.sleep(1000);
|
await this.sleep(1000);
|
||||||
try {
|
try {
|
||||||
|
if (this.periodicallyRefreshPlayerElement) {
|
||||||
|
this.forceRefreshPlayerElement();
|
||||||
|
}
|
||||||
if (this.checkPlayerSizeChange()) {
|
if (this.checkPlayerSizeChange()) {
|
||||||
this.videoData.resizer.restore();
|
this.videoData.resizer.restore();
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ import Debug from '../../conf/Debug';
|
|||||||
import PlayerData from './PlayerData';
|
import PlayerData from './PlayerData';
|
||||||
import Resizer from '../video-transform/Resizer';
|
import Resizer from '../video-transform/Resizer';
|
||||||
import ArDetector from '../ar-detect/ArDetector';
|
import ArDetector from '../ar-detect/ArDetector';
|
||||||
|
import AspectRatio from '../../../common/enums/aspect-ratio.enum';
|
||||||
|
|
||||||
class VideoData {
|
class VideoData {
|
||||||
|
|
||||||
@ -300,6 +301,11 @@ class VideoData {
|
|||||||
if (this.invalid) {
|
if (this.invalid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ar.type === AspectRatio.Fixed || ar.type === AspectRatio.FitHeight || ar.type === AspectRatio.FitHeight) {
|
||||||
|
this.player.forceRefreshPlayerElement();
|
||||||
|
}
|
||||||
|
|
||||||
this.resizer.setAr(ar, lastAr);
|
this.resizer.setAr(ar, lastAr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user