首页 > 其他 > 详细

vue使用flv视频监控组件

时间:2021-04-23 00:07:03      阅读:28      评论:0      收藏:0      [点我收藏+]

先安装flv包:亲测这个版本可行: "flv.js": "^1.5.0"

<template>
  <div>
    <video id="videoElement" controls autoplay muted width="100%"></video>
  </div>
</template>

<script>
import flvjs from ‘flv.js‘
export default {
  data() {
    return {
      flvPlayer: null
    }
  },
  mounted() {
    this.getUrl()
  },
  methods: {
    getUrl() {
      this.initVideo(‘http://1011.hlsplay.aodianyun.com/demo/game.flv‘)
    },

    initVideo(url) {
      if (flvjs.isSupported()) {
        var videoElement = document.getElementById(‘videoElement‘)
        this.flvPlayer = flvjs.createPlayer({
          type: ‘flv‘,
          isLive: true,
          hasAudio: false,
          // url: ‘http://1011.hlsplay.aodianyun.com/demo/game.flv‘
          url: url
        })
        this.flvPlayer.attachMediaElement(videoElement)
        this.flvPlayer.load()
        this.flvPlayer.play()
      }
    }
  },

  beforeDestroy() {
    //销毁事件
    this.flvPlayer.pause()
    this.flvPlayer.unload()
    this.flvPlayer.detachMediaElement()
    this.flvPlayer.destroy()
    this.flvPlayer = null
  }
}
</script>

vue使用flv视频监控组件

原文:https://www.cnblogs.com/dxy9527/p/14690283.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!