reload player on error

This commit is contained in:
jb-alvarado 2024-07-04 16:41:32 +02:00
parent e8fd6f65bf
commit 18518dd53a
3 changed files with 23 additions and 10 deletions

View File

@ -6,7 +6,7 @@
<div class="w-full aspect-video"> <div class="w-full aspect-video">
<video v-if="streamExtension === 'flv'" ref="httpStreamFlv" controls /> <video v-if="streamExtension === 'flv'" ref="httpStreamFlv" controls />
<VideoPlayer <VideoPlayer
v-else-if="configStore.configChannel[configStore.configID]" v-else-if="configStore.showPlayer && configStore.configChannel[configStore.configID]"
:key="configStore.configID" :key="configStore.configID"
class="live-player" class="live-player"
reference="httpStream" reference="httpStream"
@ -245,9 +245,9 @@ watch([status, error], async () => {
if (errorCounter.value > 11) { if (errorCounter.value > 11) {
await authStore.obtainUuid() await authStore.obtainUuid()
streamUrl.value = `/data/event/${configStore.configChannel[configStore.configID].id}?endpoint=playout&uuid=${ streamUrl.value = `/data/event/${
authStore.uuid configStore.configChannel[configStore.configID].id
}` }?endpoint=playout&uuid=${authStore.uuid}`
errorCounter.value = 0 errorCounter.value = 0
} }
} }
@ -309,7 +309,7 @@ function resetStatus() {
async function controlProcess(state: string) { async function controlProcess(state: string) {
/* /*
Control playout systemd service (start, stop, restart) Control playout (start, stop, restart)
*/ */
const channel = configStore.configChannel[configStore.configID].id const channel = configStore.configChannel[configStore.configID].id

View File

@ -15,6 +15,8 @@
import videojs from 'video.js' import videojs from 'video.js'
import 'video.js/dist/video-js.css' import 'video.js/dist/video-js.css'
const configStore = useConfig()
const player = ref() const player = ref()
const props = defineProps({ const props = defineProps({
@ -42,6 +44,16 @@ onMounted(() => {
player.value.on('volumechange', () => { player.value.on('volumechange', () => {
localStorage.setItem('volume', player.value.volume()) localStorage.setItem('volume', player.value.volume())
}) })
player.value.on('error', () => {
setTimeout(() => {
configStore.showPlayer = false
nextTick(() => {
configStore.showPlayer = true
})
}, 2000)
})
}) })
onBeforeUnmount(() => { onBeforeUnmount(() => {

View File

@ -15,6 +15,7 @@ export const useConfig = defineStore('config', {
configUser: {} as User, configUser: {} as User,
utcOffset: 0, utcOffset: 0,
onetimeInfo: true, onetimeInfo: true,
showPlayer: true,
}), }),
getters: {}, getters: {},