Merge pull request #10093 from dataease/pr@dev-v2@refactor_stream-flv

refactor(仪表板): 优化流媒体播放,解决编辑时初次设置直播地址没有及时播放问题
This commit is contained in:
王嘉豪 2024-06-04 23:48:50 +08:00 committed by GitHub
commit b48d559dfc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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()