mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-06 15:57:05 +00:00
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
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:
parent
9a02b1d430
commit
7ae937461f
@ -15,6 +15,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { type Blob, type Ref } from '@hcengineering/core'
|
import { type Blob, type Ref } from '@hcengineering/core'
|
||||||
import { getFileUrl, getVideoMeta, type BlobMetadata } from '@hcengineering/presentation'
|
import { getFileUrl, getVideoMeta, type BlobMetadata } from '@hcengineering/presentation'
|
||||||
|
import { onDestroy } from 'svelte'
|
||||||
import HLS from 'hls.js'
|
import HLS from 'hls.js'
|
||||||
|
|
||||||
export let value: Ref<Blob>
|
export let value: Ref<Blob>
|
||||||
@ -23,12 +24,14 @@
|
|||||||
export let fit: boolean = false
|
export let fit: boolean = false
|
||||||
|
|
||||||
let video: HTMLVideoElement
|
let video: HTMLVideoElement
|
||||||
|
let hls: HLS
|
||||||
|
|
||||||
async function fetchVideoMeta (value: Ref<Blob>, name: string): Promise<void> {
|
async function fetchVideoMeta (value: Ref<Blob>, name: string): Promise<void> {
|
||||||
const src = getFileUrl(value, name)
|
const src = getFileUrl(value, name)
|
||||||
const meta = await getVideoMeta(value, name)
|
const meta = await getVideoMeta(value, name)
|
||||||
if (meta != null && meta.status === 'ready' && HLS.isSupported()) {
|
if (meta != null && meta.status === 'ready' && HLS.isSupported()) {
|
||||||
const hls = new HLS()
|
hls?.destroy()
|
||||||
|
hls = new HLS()
|
||||||
hls.loadSource(meta.hls)
|
hls.loadSource(meta.hls)
|
||||||
hls.attachMedia(video)
|
hls.attachMedia(video)
|
||||||
video.poster = meta.thumbnail
|
video.poster = meta.thumbnail
|
||||||
@ -37,6 +40,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onDestroy(() => {
|
||||||
|
hls?.destroy()
|
||||||
|
})
|
||||||
|
|
||||||
$: aspectRatio =
|
$: aspectRatio =
|
||||||
metadata?.originalWidth && metadata?.originalHeight
|
metadata?.originalWidth && metadata?.originalHeight
|
||||||
? `${metadata.originalWidth} / ${metadata.originalHeight}`
|
? `${metadata.originalWidth} / ${metadata.originalHeight}`
|
||||||
|
Loading…
Reference in New Issue
Block a user