Additional fixes for player element discovery. Force player element refresh on every video element size change.

This commit is contained in:
Tamius Han 2019-08-31 22:10:51 +02:00
parent c275e389a1
commit 67f031e549
3 changed files with 11 additions and 5 deletions

View File

@ -10,16 +10,14 @@ var Debug = {
// resizer: true, // resizer: true,
// debugArDetect: true, // debugArDetect: true,
// scaler: true, // scaler: true,
// debugStorage: false,
// debugStorage: true, // debugStorage: true,
// comms: false, // comms: false,
// comms: true, // comms: true,
// showArDetectCanvas: true, // showArDetectCanvas: true,
// flushStoredSettings: true, // flushStoredSettings: true,
// flushStoredSettings: false,
// playerDetect: true, // playerDetect: true,
// periodic: true, // periodic: true,
// // videoRescan: true, // videoRescan: true,
// mousemove: true, // mousemove: true,
// arDetect: { // arDetect: {
// edgeDetect: true // edgeDetect: true

View File

@ -317,8 +317,8 @@ class PlayerData {
} }
if (elementQ.length) { if (elementQ.length) {
// return biggest score // return element with biggest score
return elementQ.sort( (a,b) => b.score - a.score)[0]; return elementQ.sort( (a,b) => b.score - a.score)[0].element;
} }
// if no candidates were found, return parent node // if no candidates were found, return parent node
@ -367,6 +367,10 @@ class PlayerData {
} }
} }
forceRefreshPlayerElement() {
this.getPlayerDimensions();
}
checkPlayerSizeChange(){ checkPlayerSizeChange(){
if(Debug.debug){ if(Debug.debug){
if(this.element == undefined){ if(this.element == undefined){
@ -395,8 +399,10 @@ class PlayerData {
} }
if(this.element == undefined){ if(this.element == undefined){
this.element = this.getPlayer();
return true; return true;
} else if(this.dimensions.width != this.element.offsetWidth || this.dimensions.height != this.element.offsetHeight ){ } else if(this.dimensions.width != this.element.offsetWidth || this.dimensions.height != this.element.offsetHeight ){
this.element = this.getPlayer();
return true; return true;
} }

View File

@ -75,10 +75,12 @@ class VideoData {
console.log("style changed") console.log("style changed")
// if size of the video has changed, this may mean we need to recalculate/reapply // if size of the video has changed, this may mean we need to recalculate/reapply
// last calculated aspect ratio // last calculated aspect ratio
this.player.forceRefreshPlayerElement();
this.restoreAr(); this.restoreAr();
} else if (mutation.attribute = 'src' && mutation.attributeOldValue !== this.video.getAttribute('src')) { } else if (mutation.attribute = 'src' && mutation.attributeOldValue !== this.video.getAttribute('src')) {
// try fixing alignment issue on video change // try fixing alignment issue on video change
try { try {
this.player.forceRefreshPlayerElement();
this.restoreAr(); this.restoreAr();
} catch (e) { } catch (e) {
console.error("[VideoData::onVideoDimensionsChanged] There was an error when handling src change.", e); console.error("[VideoData::onVideoDimensionsChanged] There was an error when handling src change.", e);