Merge pull request #10103 from dataease/pr@dev-v2@refactor_stream
refactor(仪表板、数据大屏): 优化流媒体直播,防止频繁切换直播链接造成无法播放问题
This commit is contained in:
commit
dfca84679d
@ -16,8 +16,8 @@ export const STREAMMEDIALINKS = {
|
||||
isLive: false,
|
||||
cors: true, // 允许跨域
|
||||
loop: true,
|
||||
autoplay: false
|
||||
// url: null // 网络动画视频
|
||||
autoplay: false,
|
||||
url: null // 网络动画视频
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -75,37 +75,30 @@ 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()
|
||||
const video = currentInstance.proxy.$refs['player-' + element.value.id]
|
||||
if (video) {
|
||||
try {
|
||||
state.flvPlayer = flvjs.createPlayer(state.pOption, {
|
||||
enableWorker: false, // 不启用分离线程
|
||||
enableStashBuffer: false, // 关闭IO隐藏缓冲区
|
||||
isLive: state.pOption.isLive,
|
||||
lazyLoad: false
|
||||
})
|
||||
state.flvPlayer.attachMediaElement(video)
|
||||
state.flvPlayer.load()
|
||||
state.flvPlayer.play()
|
||||
} catch (error) {
|
||||
console.error('flvjs err ignore', error)
|
||||
state.pOption = element.value.streamMediaLinks[element.value.streamMediaLinks.videoType]
|
||||
delete state.pOption.segments
|
||||
nextTick(() => {
|
||||
if (flvjs.isSupported() && state.pOption.url) {
|
||||
destroyPlayer()
|
||||
const video = currentInstance.proxy.$refs['player-' + element.value.id]
|
||||
if (video) {
|
||||
try {
|
||||
state.flvPlayer = flvjs.createPlayer(state.pOption, {
|
||||
enableWorker: false, // 不启用分离线程
|
||||
enableStashBuffer: false, // 关闭IO隐藏缓冲区
|
||||
isLive: state.pOption.isLive,
|
||||
lazyLoad: false
|
||||
})
|
||||
state.flvPlayer.attachMediaElement(video)
|
||||
state.flvPlayer.load()
|
||||
state.flvPlayer.play()
|
||||
} catch (error) {
|
||||
console.error('flvjs err ignore', error)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const destroyPlayer = () => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user