refactor(仪表板): 优化流媒体播放,解决编辑时初次设置直播地址没有及时播放问题

This commit is contained in:
wangjiahao 2024-06-04 23:47:55 +08:00
parent 3ebcd4ccd6
commit b6a3e3864d

View File

@ -21,7 +21,7 @@
<script lang="ts" setup>
import flvjs from 'flv.js'
import '@/style/custom-theme.css'
import { onMounted, reactive, toRefs, getCurrentInstance } from 'vue'
import { onMounted, reactive, toRefs, getCurrentInstance, watch, nextTick } from 'vue'
import { useEmitt } from '@/hooks/web/useEmitt'
import { useI18n } from '@/hooks/web/useI18n'
const { t } = useI18n()
@ -75,6 +75,17 @@ onMounted(() => {
initOption()
})
watch(
() => element.value.streamMediaLinks,
() => {
destroyPlayer()
nextTick(() => {
state.pOption = element.value.streamMediaLinks[element.value.streamMediaLinks.videoType]
initOption()
})
}
)
const initOption = () => {
if (flvjs.isSupported() && state.pOption.url) {
destroyPlayer()