fix: destroy hls player on destroy (#7821)
Some checks are pending
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions

Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
Alexander Onnikov 2025-01-29 12:03:13 +07:00 committed by GitHub
parent 9a02b1d430
commit 7ae937461f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -15,6 +15,7 @@
<script lang="ts">
import { type Blob, type Ref } from '@hcengineering/core'
import { getFileUrl, getVideoMeta, type BlobMetadata } from '@hcengineering/presentation'
import { onDestroy } from 'svelte'
import HLS from 'hls.js'
export let value: Ref<Blob>
@ -23,12 +24,14 @@
export let fit: boolean = false
let video: HTMLVideoElement
let hls: HLS
async function fetchVideoMeta (value: Ref<Blob>, name: string): Promise<void> {
const src = getFileUrl(value, name)
const meta = await getVideoMeta(value, name)
if (meta != null && meta.status === 'ready' && HLS.isSupported()) {
const hls = new HLS()
hls?.destroy()
hls = new HLS()
hls.loadSource(meta.hls)
hls.attachMedia(video)
video.poster = meta.thumbnail
@ -37,6 +40,10 @@
}
}
onDestroy(() => {
hls?.destroy()
})
$: aspectRatio =
metadata?.originalWidth && metadata?.originalHeight
? `${metadata.originalWidth} / ${metadata.originalHeight}`