Don't restore ar if player dimensions haven't changed
This commit is contained in:
parent
691f45fbcc
commit
1588ebd274
@ -215,7 +215,8 @@ class PlayerData {
|
|||||||
getPlayer() {
|
getPlayer() {
|
||||||
const host = window.location.host;
|
const host = window.location.host;
|
||||||
let element = this.video.parentNode;
|
let element = this.video.parentNode;
|
||||||
const videoWidth = this.video.offsetWidth, videoHeight = this.video.offsetHeight;
|
const videoWidth = this.video.offsetWidth;
|
||||||
|
const videoHeight = this.video.offsetHeight;
|
||||||
const elementQ = [];
|
const elementQ = [];
|
||||||
let scorePenalty = 0;
|
let scorePenalty = 0;
|
||||||
let score;
|
let score;
|
||||||
@ -352,6 +353,20 @@ class PlayerData {
|
|||||||
return a > b - tolerance && a < b + tolerance;
|
return a > b - tolerance && a < b + tolerance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
forceDetectPlayerElementChange() {
|
||||||
|
// save current dimensions before refreshing the player object
|
||||||
|
const oldDimensions = this.dimensions;
|
||||||
|
this.getPlayer();
|
||||||
|
|
||||||
|
// compare new player object dimensions with the old dimensions
|
||||||
|
// don't fucking trigger changes if nothing changed
|
||||||
|
if (this.dimensions.width === this.dimensions.width && this.dimensions.height === this.dimensions.height) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
forceRefreshPlayerElement() {
|
forceRefreshPlayerElement() {
|
||||||
this.getPlayer();
|
this.getPlayer();
|
||||||
}
|
}
|
||||||
|
@ -154,8 +154,12 @@ class VideoData {
|
|||||||
&& this.isWithin(vh, (ph - (translateY * 2)), 2)
|
&& this.isWithin(vh, (ph - (translateY * 2)), 2)
|
||||||
&& this.isWithin(vw, (pw - (translateX * 2)), 2)) {
|
&& this.isWithin(vw, (pw - (translateX * 2)), 2)) {
|
||||||
} else {
|
} else {
|
||||||
this.player.forceRefreshPlayerElement();
|
if (this.player.forceDetectPlayerElementChange()) {
|
||||||
this.restoreAr();
|
this.logger.log('info', 'debug', "Video dimensions changed. Triggering restoreAr()");
|
||||||
|
this.restoreAr();
|
||||||
|
} else {
|
||||||
|
this.logger.log('info', 'playerRescan', "Video dimensions didn't change.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user