web/libav: move pre-init to onMount

This commit is contained in:
dumbmoron 2024-09-03 18:44:43 +00:00
parent 2b987a6efb
commit 6c4c5fd4f2
No known key found for this signature in database
2 changed files with 5 additions and 12 deletions

View file

@ -2,13 +2,12 @@
import mime from "mime";
import LibAVWrapper from "$lib/libav/remux";
import { onDestroy } from "svelte";
import { onDestroy, onMount } from "svelte";
import { beforeNavigate, goto } from "$app/navigation";
import { t } from "$lib/i18n/translations";
import { createDialog } from "$lib/dialogs";
import { downloadFile } from "$lib/download";
import { browser } from "$app/environment";
import Skeleton from "$components/misc/Skeleton.svelte";
import DropReceiver from "$components/misc/DropReceiver.svelte";
@ -53,13 +52,9 @@
}
});
if (browser) {
ff.init();
}
const render = async () => {
if (!file || processing) return;
await ff.init();
ff.init();
let dialogOpened;
try {
@ -199,6 +194,7 @@
render();
}
onMount(() => ff.init());
onDestroy(() => ff.terminate());
</script>

View file

@ -7,16 +7,12 @@
import DropReceiver from "$components/misc/DropReceiver.svelte";
import FileReceiver from "$components/misc/FileReceiver.svelte";
import type { StreamInfo } from "$lib/types/libav";
import { onDestroy } from "svelte";
import { onDestroy, onMount } from "svelte";
let file: File | undefined;
let streamInfo: StreamInfo[] | undefined;
const ff = new LibAVWrapper();
if (browser) {
ff.init();
}
const render = async () => {
if (!file) return;
await ff.init();
@ -58,6 +54,7 @@
pseudolink.click();
};
onMount(() => ff.init());
onDestroy(async () => {
if (browser) {
await ff.cleanup();