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;
}
#game-stream video {
visibility: hidden;
}
`;
// Reduce animations
@ -782,17 +785,25 @@ function patchVideoApi() {
HTMLMediaElement.prototype.orgPlay = HTMLMediaElement.prototype.play;
HTMLMediaElement.prototype.play = function() {
if (!this.className.startsWith('XboxSplashVideo')) {
return this.orgPlay.apply(this);
if (this.className.startsWith('XboxSplashVideo')) {
this.volume = 0;
this.style.display = 'none';
this.dispatchEvent(new Event('ended'));
return {
catch: () => {},
};
}
this.volume = 0;
this.style.display = 'none';
this.dispatchEvent(new Event('ended'));
// Show video player when it's ready
let showFunc;
showFunc = function() {
this.style.visibility = 'visible';
this.removeEventListener('playing', showFunc);
}
this.addEventListener('playing', showFunc);
return {
catch: () => {},
};
return this.orgPlay.apply(this);
};
}