其他分享
首页 > 其他分享> > 2021-06-11

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>

标签:11,06,flvPlayer,createVideo,flv,2021,var,videoElement,flvjs
来源: https://blog.csdn.net/qq_44091061/article/details/117821912