diff --git a/src/ext/conf/Debug.js b/src/ext/conf/Debug.js index 9c3e9bf..d1b8387 100644 --- a/src/ext/conf/Debug.js +++ b/src/ext/conf/Debug.js @@ -10,16 +10,14 @@ var Debug = { // resizer: true, // debugArDetect: true, // scaler: true, - // debugStorage: false, // debugStorage: true, // comms: false, // comms: true, // showArDetectCanvas: true, // flushStoredSettings: true, - // flushStoredSettings: false, // playerDetect: true, // periodic: true, - // // videoRescan: true, + // videoRescan: true, // mousemove: true, // arDetect: { // edgeDetect: true diff --git a/src/ext/lib/video-data/PlayerData.js b/src/ext/lib/video-data/PlayerData.js index a3633f4..acbda74 100644 --- a/src/ext/lib/video-data/PlayerData.js +++ b/src/ext/lib/video-data/PlayerData.js @@ -317,8 +317,8 @@ class PlayerData { } if (elementQ.length) { - // return biggest score - return elementQ.sort( (a,b) => b.score - a.score)[0]; + // return element with biggest score + return elementQ.sort( (a,b) => b.score - a.score)[0].element; } // if no candidates were found, return parent node @@ -367,6 +367,10 @@ class PlayerData { } } + forceRefreshPlayerElement() { + this.getPlayerDimensions(); + } + checkPlayerSizeChange(){ if(Debug.debug){ if(this.element == undefined){ @@ -395,8 +399,10 @@ class PlayerData { } if(this.element == undefined){ + this.element = this.getPlayer(); return true; } else if(this.dimensions.width != this.element.offsetWidth || this.dimensions.height != this.element.offsetHeight ){ + this.element = this.getPlayer(); return true; } diff --git a/src/ext/lib/video-data/VideoData.js b/src/ext/lib/video-data/VideoData.js index 7f8be7a..8d4b7f6 100644 --- a/src/ext/lib/video-data/VideoData.js +++ b/src/ext/lib/video-data/VideoData.js @@ -75,10 +75,12 @@ class VideoData { console.log("style changed") // if size of the video has changed, this may mean we need to recalculate/reapply // last calculated aspect ratio + this.player.forceRefreshPlayerElement(); this.restoreAr(); } else if (mutation.attribute = 'src' && mutation.attributeOldValue !== this.video.getAttribute('src')) { // try fixing alignment issue on video change try { + this.player.forceRefreshPlayerElement(); this.restoreAr(); } catch (e) { console.error("[VideoData::onVideoDimensionsChanged] There was an error when handling src change.", e);