Force fallback mode, always.
This commit is contained in:
parent
469c607568
commit
7b73a42e5c
@ -86,6 +86,7 @@ class PlayerData {
|
|||||||
if (this.invalid) {
|
if (this.invalid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ths = this;
|
const ths = this;
|
||||||
this.observer = new MutationObserver((m,o) => this.onPlayerDimensionsChanged(m,o,ths));
|
this.observer = new MutationObserver((m,o) => this.onPlayerDimensionsChanged(m,o,ths));
|
||||||
|
|
||||||
@ -96,7 +97,21 @@ class PlayerData {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.observer.observe(this.element, observerConf);
|
this.observer.observe(this.element, observerConf);
|
||||||
|
|
||||||
|
// 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async legacyChangeDetection() {
|
||||||
|
while (!this.halted) {
|
||||||
|
await this.sleep(1000);
|
||||||
|
if (this.checkPlayerSizeChange()) {
|
||||||
|
this.videoData.restore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
stopChangeDetection(){
|
stopChangeDetection(){
|
||||||
this.observer.disconnect();
|
this.observer.disconnect();
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,11 @@ class VideoData {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.dimensions = {
|
||||||
|
width: this.video.offsetWidth,
|
||||||
|
height: this.video.offsetHeight,
|
||||||
|
};
|
||||||
|
|
||||||
this.resizer = new Resizer(this);
|
this.resizer = new Resizer(this);
|
||||||
this.arDetector = new ArDetector(this); // this starts Ar detection. needs optional parameter that prevets ardetdctor from starting
|
this.arDetector = new ArDetector(this); // this starts Ar detection. needs optional parameter that prevets ardetdctor from starting
|
||||||
// player dimensions need to be in:
|
// player dimensions need to be in:
|
||||||
@ -56,7 +61,7 @@ class VideoData {
|
|||||||
|
|
||||||
async fallbackChangeDetection() {
|
async fallbackChangeDetection() {
|
||||||
while (!this.destroyed && !this.invalid) {
|
while (!this.destroyed && !this.invalid) {
|
||||||
await this.sleep(1000);
|
await this.sleep(500);
|
||||||
this.validateVideoOffsets();
|
this.validateVideoOffsets();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -368,6 +373,37 @@ class VideoData {
|
|||||||
isPlaying() {
|
isPlaying() {
|
||||||
return this.video && this.video.currentTime > 0 && !this.video.paused && !this.video.ended;
|
return this.video && this.video.currentTime > 0 && !this.video.paused && !this.video.ended;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkVideoSizeChange(){
|
||||||
|
const videoWidth = this.video.offsetWidth;
|
||||||
|
const videoHeight = this.video.offsetHeight;
|
||||||
|
// this 'if' is just here for debugging — real code starts later. It's safe to collapse and
|
||||||
|
// ignore the contents of this if (unless we need to change how logging works)
|
||||||
|
if (this.logger.canLog('debug')){
|
||||||
|
if(! this.video) {
|
||||||
|
this.logger.log('info', 'videoDetect', "[VideoDetect] player element isn't defined");
|
||||||
|
}
|
||||||
|
if ( this.video && this.dimensions &&
|
||||||
|
( this.dimensions.width != videoWidth ||
|
||||||
|
this.dimensions.height != videoHeight )
|
||||||
|
) {
|
||||||
|
this.logger.log('info', 'debug', "[VideoDetect] player size changed. reason: dimension change. Old dimensions?", this.dimensions.width, this.dimensions.height, "new dimensions:", this.video.offsetWidth, this.video.offsetHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if size doesn't match, update & return true
|
||||||
|
if (!this.dimensions
|
||||||
|
|| this.dimensions.width != videoWidth
|
||||||
|
|| this.dimensions.height != videoHeight ){
|
||||||
|
this.dimensions = {
|
||||||
|
width: videoWidth,
|
||||||
|
height: videoHeight,
|
||||||
|
};
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default VideoData;
|
export default VideoData;
|
||||||
|
Loading…
Reference in New Issue
Block a user