Hide video player until it's ready

This commit is contained in:
redphx 2023-07-15 09:40:13 +07:00
parent 0e2066e461
commit a9eb70eaae

View File

@ -284,6 +284,9 @@ div[class*=NotFocusedDialog] {
height: 0px !important; height: 0px !important;
} }
#game-stream video {
visibility: hidden;
}
`; `;
// Reduce animations // Reduce animations
@ -782,17 +785,25 @@ function patchVideoApi() {
HTMLMediaElement.prototype.orgPlay = HTMLMediaElement.prototype.play; HTMLMediaElement.prototype.orgPlay = HTMLMediaElement.prototype.play;
HTMLMediaElement.prototype.play = function() { HTMLMediaElement.prototype.play = function() {
if (!this.className.startsWith('XboxSplashVideo')) { if (this.className.startsWith('XboxSplashVideo')) {
return this.orgPlay.apply(this); this.volume = 0;
this.style.display = 'none';
this.dispatchEvent(new Event('ended'));
return {
catch: () => {},
};
} }
this.volume = 0; // Show video player when it's ready
this.style.display = 'none'; let showFunc;
this.dispatchEvent(new Event('ended')); showFunc = function() {
this.style.visibility = 'visible';
this.removeEventListener('playing', showFunc);
}
this.addEventListener('playing', showFunc);
return { return this.orgPlay.apply(this);
catch: () => {},
};
}; };
} }