Formatting

This commit is contained in:
2026-01-09 00:15:50 +01:00
parent 773021c456
commit e8e2f9be15
2 changed files with 6 additions and 24 deletions

View File

@@ -1,14 +1,7 @@
import { isAudioAsset } from "../media/audio.js"; import { isAudioAsset } from "../media/audio.js";
import { isGifAsset, isVideoAsset, isVideoElement } from "./assetKinds.js"; import { isGifAsset, isVideoAsset, isVideoElement } from "./assetKinds.js";
export function createMediaManager({ export function createMediaManager({ state, audioManager, draw, obsBrowser, supportsAnimatedDecode, canPlayProbe }) {
state,
audioManager,
draw,
obsBrowser,
supportsAnimatedDecode,
canPlayProbe,
}) {
const { mediaCache, animatedCache, blobCache, animationFailures, videoPlaybackStates } = state; const { mediaCache, animatedCache, blobCache, animationFailures, videoPlaybackStates } = state;
function clearMedia(assetId) { function clearMedia(assetId) {

View File

@@ -20,9 +20,7 @@ export class BroadcastRenderer {
this.obsBrowser = !!globalThis.obsstudio; this.obsBrowser = !!globalThis.obsstudio;
this.supportsAnimatedDecode = this.supportsAnimatedDecode =
typeof ImageDecoder !== "undefined" && typeof ImageDecoder !== "undefined" && typeof createImageBitmap === "function" && !this.obsBrowser;
typeof createImageBitmap === "function" &&
!this.obsBrowser;
this.canPlayProbe = document.createElement("video"); this.canPlayProbe = document.createElement("video");
this.audioManager = createAudioManager({ assets: this.state.assets }); this.audioManager = createAudioManager({ assets: this.state.assets });
@@ -65,9 +63,7 @@ export class BroadcastRenderer {
return r.json(); return r.json();
}) })
.then((assets) => this.renderAssets(assets)) .then((assets) => this.renderAssets(assets))
.catch(() => .catch(() => this.showToast("Unable to load overlay assets. Retrying may help.", "error"));
this.showToast("Unable to load overlay assets. Retrying may help.", "error"),
);
}); });
} }
@@ -127,21 +123,14 @@ export class BroadcastRenderer {
if (!settings) { if (!settings) {
return; return;
} }
const width = Number.isFinite(settings.width) const width = Number.isFinite(settings.width) ? settings.width : this.state.canvasSettings.width;
? settings.width const height = Number.isFinite(settings.height) ? settings.height : this.state.canvasSettings.height;
: this.state.canvasSettings.width;
const height = Number.isFinite(settings.height)
? settings.height
: this.state.canvasSettings.height;
this.state.canvasSettings = { width, height }; this.state.canvasSettings = { width, height };
this.resizeCanvas(); this.resizeCanvas();
} }
resizeCanvas() { resizeCanvas() {
if ( if (Number.isFinite(this.state.canvasSettings.width) && Number.isFinite(this.state.canvasSettings.height)) {
Number.isFinite(this.state.canvasSettings.width) &&
Number.isFinite(this.state.canvasSettings.height)
) {
this.canvas.width = this.state.canvasSettings.width; this.canvas.width = this.state.canvasSettings.width;
this.canvas.height = this.state.canvasSettings.height; this.canvas.height = this.state.canvasSettings.height;
this.canvas.style.width = `${this.state.canvasSettings.width}px`; this.canvas.style.width = `${this.state.canvasSettings.width}px`;