2021-06-11

vue中使用flv.js播放视频

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

<script>
import flvjs from 'flv.js'

export default {
  name: 'App',
  components: {
  },
  mounted() {
    this.$nextTick(() => {
      this.createVideo()
    })
  },
  methods: {
    createVideo() {
      if (flvjs.isSupported()) {
        var videoElement = document.getElementById('videoElement');
        var flvPlayer = flvjs.createPlayer({
          type: 'flv',
          url: 'http://platform.firerobot-online.com:7001/live/RXZ-MC52-L1A01-0016.flv' //你的url地址
        });
        flvPlayer.attachMediaElement(videoElement);
        flvPlayer.load();
        flvPlayer.play();
      }
    }
  }
}
</script>
上一篇:vlc+flv.js 摄像头 H5 直播


下一篇:灰度图像的直方图统计增强(Matlab)