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,10 +785,7 @@ 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.volume = 0;
this.style.display = 'none'; this.style.display = 'none';
this.dispatchEvent(new Event('ended')); this.dispatchEvent(new Event('ended'));
@ -793,6 +793,17 @@ function patchVideoApi() {
return { return {
catch: () => {}, catch: () => {},
}; };
}
// Show video player when it's ready
let showFunc;
showFunc = function() {
this.style.visibility = 'visible';
this.removeEventListener('playing', showFunc);
}
this.addEventListener('playing', showFunc);
return this.orgPlay.apply(this);
}; };
} }