多维表格
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.1 KiB

<script setup lang="ts">
import Plyr from 'plyr'
import 'plyr/dist/plyr.css'
interface Props {
src?: string[]
mimeType?: string
class?: string
title?: string
}
const props = withDefaults(defineProps<Props>(), {
4 months ago
class: '',
})
const emit = defineEmits<Emits>()
interface Emits {
(event: 'init', player: any): void
(event: 'error'): void
}
const videoPlayer = ref<HTMLElement>()
const player = ref()
onMounted(() => {
if (!videoPlayer.value) return
player.value = new Plyr(videoPlayer.value, {
previewThumbnails: {},
})
emit('init', player.value)
})
onBeforeUnmount(() => {
if (player.value) {
player.value.destroy()
}
})
const handleError = async () => {
const isURLExp = await isURLExpired(props.src?.[0])
if (isURLExp.isExpired) {
emit('error')
}
}
</script>
<template>
4 months ago
<video
ref="videoPlayer"
controls
playsinline
:class="{
[props.class]: props.class,
}"
class="videoplayer !min-w-128 !min-h-72 w-full"
@error="handleError"
>
4 months ago
<source v-for="(source, id) in props.src" :key="id" :src="source" :type="mimeType" />
</video>
</template>
<style scoped lang="scss"></style>