web/libav: move pre-init to onMount
This commit is contained in:
parent
2b987a6efb
commit
6c4c5fd4f2
2 changed files with 5 additions and 12 deletions
|
@ -2,13 +2,12 @@
|
||||||
import mime from "mime";
|
import mime from "mime";
|
||||||
import LibAVWrapper from "$lib/libav/remux";
|
import LibAVWrapper from "$lib/libav/remux";
|
||||||
|
|
||||||
import { onDestroy } from "svelte";
|
import { onDestroy, onMount } from "svelte";
|
||||||
import { beforeNavigate, goto } from "$app/navigation";
|
import { beforeNavigate, goto } from "$app/navigation";
|
||||||
|
|
||||||
import { t } from "$lib/i18n/translations";
|
import { t } from "$lib/i18n/translations";
|
||||||
import { createDialog } from "$lib/dialogs";
|
import { createDialog } from "$lib/dialogs";
|
||||||
import { downloadFile } from "$lib/download";
|
import { downloadFile } from "$lib/download";
|
||||||
import { browser } from "$app/environment";
|
|
||||||
|
|
||||||
import Skeleton from "$components/misc/Skeleton.svelte";
|
import Skeleton from "$components/misc/Skeleton.svelte";
|
||||||
import DropReceiver from "$components/misc/DropReceiver.svelte";
|
import DropReceiver from "$components/misc/DropReceiver.svelte";
|
||||||
|
@ -53,13 +52,9 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (browser) {
|
|
||||||
ff.init();
|
|
||||||
}
|
|
||||||
|
|
||||||
const render = async () => {
|
const render = async () => {
|
||||||
if (!file || processing) return;
|
if (!file || processing) return;
|
||||||
await ff.init();
|
ff.init();
|
||||||
|
|
||||||
let dialogOpened;
|
let dialogOpened;
|
||||||
try {
|
try {
|
||||||
|
@ -199,6 +194,7 @@
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMount(() => ff.init());
|
||||||
onDestroy(() => ff.terminate());
|
onDestroy(() => ff.terminate());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -7,16 +7,12 @@
|
||||||
import DropReceiver from "$components/misc/DropReceiver.svelte";
|
import DropReceiver from "$components/misc/DropReceiver.svelte";
|
||||||
import FileReceiver from "$components/misc/FileReceiver.svelte";
|
import FileReceiver from "$components/misc/FileReceiver.svelte";
|
||||||
import type { StreamInfo } from "$lib/types/libav";
|
import type { StreamInfo } from "$lib/types/libav";
|
||||||
import { onDestroy } from "svelte";
|
import { onDestroy, onMount } from "svelte";
|
||||||
|
|
||||||
let file: File | undefined;
|
let file: File | undefined;
|
||||||
let streamInfo: StreamInfo[] | undefined;
|
let streamInfo: StreamInfo[] | undefined;
|
||||||
|
|
||||||
const ff = new LibAVWrapper();
|
const ff = new LibAVWrapper();
|
||||||
if (browser) {
|
|
||||||
ff.init();
|
|
||||||
}
|
|
||||||
|
|
||||||
const render = async () => {
|
const render = async () => {
|
||||||
if (!file) return;
|
if (!file) return;
|
||||||
await ff.init();
|
await ff.init();
|
||||||
|
@ -58,6 +54,7 @@
|
||||||
pseudolink.click();
|
pseudolink.click();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onMount(() => ff.init());
|
||||||
onDestroy(async () => {
|
onDestroy(async () => {
|
||||||
if (browser) {
|
if (browser) {
|
||||||
await ff.cleanup();
|
await ff.cleanup();
|
||||||
|
|
Loading…
Reference in a new issue