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}',
|
||||
},
|
||||
"www.disneyplus.com": {
|
||||
DOM: {
|
||||
player: {
|
||||
periodicallyRefreshPlayerElement: true,
|
||||
}
|
||||
}
|
||||
},
|
||||
"imgur.com": {
|
||||
mode: -1,
|
||||
autoar: -1,
|
||||
|
@ -45,6 +45,13 @@ class PlayerData {
|
||||
this.dimensions = 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
|
||||
if (!this.element) {
|
||||
this.invalid = true;
|
||||
@ -98,19 +105,19 @@ class PlayerData {
|
||||
}
|
||||
|
||||
try {
|
||||
const ths = this;
|
||||
this.observer = new MutationObserver((m,o) => this.onPlayerDimensionsChanged(m,o,ths));
|
||||
const ths = this;
|
||||
this.observer = new MutationObserver((m,o) => this.onPlayerDimensionsChanged(m,o,ths));
|
||||
|
||||
const observerConf = {
|
||||
attributes: true,
|
||||
// attributeFilter: ['style', 'class'],
|
||||
attributeOldValue: true,
|
||||
};
|
||||
|
||||
this.observer.observe(this.element, observerConf);
|
||||
} catch (e) {
|
||||
console.error("failed to set observer",e )
|
||||
}
|
||||
const observerConf = {
|
||||
attributes: true,
|
||||
// attributeFilter: ['style', 'class'],
|
||||
attributeOldValue: true,
|
||||
};
|
||||
|
||||
this.observer.observe(this.element, observerConf);
|
||||
} catch (e) {
|
||||
console.error("failed to set observer",e )
|
||||
}
|
||||
// legacy mode still exists, but acts as a fallback for observers and is triggered less
|
||||
// frequently in order to avoid too many pointless checks
|
||||
this.legacyChangeDetection();
|
||||
@ -120,6 +127,9 @@ class PlayerData {
|
||||
while (!this.halted) {
|
||||
await this.sleep(1000);
|
||||
try {
|
||||
if (this.periodicallyRefreshPlayerElement) {
|
||||
this.forceRefreshPlayerElement();
|
||||
}
|
||||
if (this.checkPlayerSizeChange()) {
|
||||
this.videoData.resizer.restore();
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ import Debug from '../../conf/Debug';
|
||||
import PlayerData from './PlayerData';
|
||||
import Resizer from '../video-transform/Resizer';
|
||||
import ArDetector from '../ar-detect/ArDetector';
|
||||
import AspectRatio from '../../../common/enums/aspect-ratio.enum';
|
||||
|
||||
class VideoData {
|
||||
|
||||
@ -300,6 +301,11 @@ class VideoData {
|
||||
if (this.invalid) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ar.type === AspectRatio.Fixed || ar.type === AspectRatio.FitHeight || ar.type === AspectRatio.FitHeight) {
|
||||
this.player.forceRefreshPlayerElement();
|
||||
}
|
||||
|
||||
this.resizer.setAr(ar, lastAr);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user