济菏高速业务端

72 lines
1.5 KiB

1 year ago
<template>
1 year ago
<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" />
1 year ago
</template>
<script>
import { HttpLivePlayer, openLiveVideo } from "./videoStream.js"
1 year ago
export default {
name: 'Video',
data() {
1 year ago
return {
player: null
1 year ago
}
},
1 year ago
props: {
camId: {
type: String,
default: null
},
pileNum: {
type: String,
default: null
},
1 year ago
url: {
type: String,
default: null
},
1 year ago
videoType: {
type: String,
default: 'flv'
},
rangeIndex: {
default: 0
1 year ago
}
},
watch: {
camId: {
handler(newV) {
1 year ago
this.playVideo();
}
// immediate: true
1 year ago
}
},
async mounted() {
1 year ago
// setTimeout(() => {
// this.$nextTick(() => {
this.playVideo();
this.$once("hook:beforeDestroy", () => this.player?.destroy());
1 year ago
// })
// })
1 year ago
},
methods: {
1 year ago
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 });
}
}
1 year ago
}
}
</script>
<style lang='scss' scoped>
.video-stream {
background-color: #000;
}
</style>