mirror of
https://github.com/imgfloat/server.git
synced 2026-02-05 03:39:26 +00:00
Formatting
This commit is contained in:
@@ -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) {
|
||||||
|
|||||||
@@ -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`;
|
||||||
|
|||||||
Reference in New Issue
Block a user