From a9eb70eaae9b608917160b8826b86684e113c2b6 Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Sat, 15 Jul 2023 09:40:13 +0700 Subject: [PATCH] Hide video player until it's ready --- better-xcloud.user.js | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/better-xcloud.user.js b/better-xcloud.user.js index e9125ea..7c41e3a 100644 --- a/better-xcloud.user.js +++ b/better-xcloud.user.js @@ -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); }; }