flvvideo.vue 2.18 KB
<template>
  <div class="ocxbox">
    <video id="flvvideo"  autoplay  style="width: 100%; height: 100%" class="fvideo"></video>
    <div class="control" hidden>
    
      <!-- <span :class="{'el-icon-full-screen':!furllstatus,'el-icon-circle-close':furllstatus,'videostatus':true, 'full-icon':true}" @click="fullvideo" id="full"></span> -->
    </div>
  </div>
</template>
<script>


export default {
  data() {
    return {
      show: true,
      videostatus: false,
      furllstatus: false,
      player: "",
    };
  },
  computed: {},
  methods: {
    initflv() {
      if (flvjs.isSupported()) {
        this.player = flv.createPlayer({
          type: "flv",
        });
      }
    },
    startFunc(url) {
      let playerel = document.getElementById("flvvideo");
      // if (typeof player !== "undefined") {
      //   if (this.player != null) {
      //     // this.player.unload();
      //     // this.player.detachMediaElement();
      //     // this.player.destroy();
      //     // this.player = null;
      //     this.flv_destroy();
      //   }
      // }
      this.player = flvjs.createPlayer({
        type: "flv",
        isLive: true,
        hasAudio: false,
        url: url,
      });
      this.player.attachMediaElement(playerel);
      this.player.load();
      this.player.play();
    },
    flv_start() {
      this.player.play();
    },
    flv_pause() {
      this.player.pause();
    },
    flv_destroy() {
      this.player.pause();
      this.player.unload();
      this.player.detachMediaElement();
      this.player.destroy();
      this.player = null;
    },
  },
  mounted() {},
};
</script>
<style lang="stylus">
.ocxbox {
  height: 100%;
  position: relative;

  .fvideo {
    height: 100%;
    width: 100%;
  }

  .control {
    position: absolute;
    bottom: 0;
    height: 40px;
    width: 100%;
    background: rgba(255, 255, 255, 0.2);
    display: none;

    .videostatus {
      cursor: pointer;
      color: #fff;
      font-size: 30px;
      line-height: 40px;
      padding-left: 10px;
    }

    .full-icon {
      float: right;
      margin-right: 20px;
      font-size: 25px;
    }
  }
}

.ocxbox:hover {
  .control {
    // display block
    cursor: pointer;
  }
}
</style>