封装 视频以及监控组件

1.引入插件。

文件Git 地址:

https://gitee.com/wang-xiaowang123/liveplayer

.html 文件中

<script src="/assets/js/liveplayer-lib.min.js" exclude></script>
// liveplayer-lib.min.js 文件在Git仓库中

在这里插入图片描述

2.封装组件

LivePlayerDemo.vue

<template>
  <div style="width: auto; height: auto; margin: auto" class="palyer2">
    <LivePlayer ref="player2" live :video-url="flvurl" :controls="false" :aspect="aspect" />
  </div>
</template>
<script setup>
import LivePlayer from '@liveqing/liveplayer-v3'
const props = defineProps({
    
    
  flvurl: String,
  aspect: {
    
     type: String, default: '' }
})

let {
    
     flvurl, aspect } = toRefs(props)
</script>

<style scoped></style>

3.使用

<template>
    <div class="CameraPhoto">
        <LivePlayerDemo v-if="list.URL" :autoplay="true" :flvurl="list.URL" :poster="poster" />
        <img v-else :src="list.image" alt="" />
    </div>
</template>

<script setup>
import LivePlayerDemo from '@/components/LivePlayerDemo.vue'
const list = reactive({
    
    
		  id: '5',
          Name: '1',
          image: '/assets/img/common/videoSurve01.png',
          URL: 'ws://223.108.188.12:10800/ws-flv/hls.flv'
	})
const poster = '/assets/img/common/videoSurve01.png'
</script>

<style lang="scss" scoped>
  .palyer2 {
    
    
      width: 322px;
      height: 181px;
    img {
    
    
      width: 100%;
      height: 100%;
  	}
  }
</style>

猜你喜欢

转载自blog.csdn.net/weixin_55042716/article/details/131791504