Additional fixes for player element discovery. Force player element refresh on every video element size change.
This commit is contained in:
parent
c275e389a1
commit
67f031e549
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user