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.
71 lines
1.5 KiB
71 lines
1.5 KiB
<template>
|
|
<video v-if="videoType == 'mp4'" controls muted class="video-stream" v-bind="$attrs" ref="videoContainerRef">
|
|
<source :src="url" type="video/mp4">
|
|
</video>
|
|
<video v-else controls autoplay muted class="video-stream" v-bind="$attrs" ref="videoContainerRef" />
|
|
</template>
|
|
|
|
<script>
|
|
import { HttpLivePlayer, openLiveVideo } from "./videoStream.js"
|
|
|
|
export default {
|
|
name: 'Video',
|
|
data() {
|
|
return {
|
|
player: null
|
|
}
|
|
},
|
|
props: {
|
|
camId: {
|
|
type: String,
|
|
default: null
|
|
},
|
|
pileNum: {
|
|
type: String,
|
|
default: null
|
|
},
|
|
url: {
|
|
type: String,
|
|
default: null
|
|
},
|
|
videoType: {
|
|
type: String,
|
|
default: 'flv'
|
|
},
|
|
rangeIndex: {
|
|
default: 0
|
|
}
|
|
},
|
|
watch: {
|
|
camId: {
|
|
handler(newV) {
|
|
this.playVideo();
|
|
}
|
|
// immediate: true
|
|
}
|
|
},
|
|
async mounted() {
|
|
// setTimeout(() => {
|
|
// this.$nextTick(() => {
|
|
this.playVideo();
|
|
this.$once("hook:beforeDestroy", () => this.player?.destroy());
|
|
// })
|
|
// })
|
|
},
|
|
methods: {
|
|
playVideo() {
|
|
this.player?.destroy();
|
|
if (this.videoType == 'flv') {
|
|
// const player = await openLiveVideo(this.$refs.videoContainerRef, { camId: this.camId, url: this.url, pileNum: this.pileNum })
|
|
this.player = new HttpLivePlayer(this.$refs.videoContainerRef, { camId: this.camId, url: this.url, pileNum: this.pileNum, rangeIndex: this.rangeIndex });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang='scss' scoped>
|
|
.video-stream {
|
|
background-color: #000;
|
|
}
|
|
</style>
|
|
|