From 4abf817f2ad46d7517c6a744ef7958146fe1a12b Mon Sep 17 00:00:00 2001 From: Jade Macho Date: Tue, 14 Jan 2025 22:25:09 +0100 Subject: [PATCH] PFA: Fix wanted width being ignored on re-updates --- mods/jade/PatchFirefoxAnamorphic.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/mods/jade/PatchFirefoxAnamorphic.js b/mods/jade/PatchFirefoxAnamorphic.js index 0d5028b..d7e19ac 100644 --- a/mods/jade/PatchFirefoxAnamorphic.js +++ b/mods/jade/PatchFirefoxAnamorphic.js @@ -9,6 +9,8 @@ import JadefinUtils from "../../JadefinUtils.js"; // Thanks, Mozilla, for killing Firefox... https://bugzilla.mozilla.org/show_bug.cgi?id=1331110 export default JadefinIntegrity("PatchFirefoxAnamorphic", import.meta.url, () => new (class PatchFirefoxAnamorphic extends JadefinMod { + wantedWidth = 0; + constructor() { super(); } @@ -51,15 +53,22 @@ export default JadefinIntegrity("PatchFirefoxAnamorphic", import.meta.url, () => } if (this.video == video) { - return this._dispatch(0); + return this._dispatch(this.wantedWidth); + } + + const streams = JadefinUtils.currentPlayer?.streamInfo?.mediaSource?.MediaStreams; + if (!streams) { + this.log.i("Waiting for media streams"); + setTimeout(() => this.update(), 100); + return; } this.video = video; - const ratioStr = JadefinUtils.currentPlayer.streamInfo.mediaSource.MediaStreams.find(s => s.Type == "Video").AspectRatio; + const ratioStr = streams.find(s => s.Type == "Video").AspectRatio; const ratioStrSplit = ratioStr && ratioStr.split(":"); if (!ratioStrSplit || !ratioStrSplit[1]) { - this.log.i(`Aspect ratio couldn't be determined`); + this.log.i("Aspect ratio couldn't be determined"); return this._dispatch(0); } @@ -81,6 +90,8 @@ export default JadefinIntegrity("PatchFirefoxAnamorphic", import.meta.url, () => * @param {number} width */ _dispatch(width) { + this.wantedWidth = width; + JadefinUtils.events.dispatchEvent(new CustomEvent("PatchFirefoxAnamorphic", { detail: { width