ytVideo.vue 2.55 KB
<template>
  <div class="item">
    <div class="player">
      <div class="ocx-box">
        <object id="VionVideo" classid="clsid:96DFBBAF-4220-4978-9681-4ABA534A7718"
          width="98%" height="550" style="margin-left:.9%">
        </object>
      </div>
    </div>
  </div>
</template>
<script>
import {mapState} from 'vuex'
export default {
    data() {
      return {};
    },
    props: ['playurl', 'type'],
    methods: {
      videoPlay: function () {
        this.urlFlag = false
        if (!this.playurl.sip_serv_ip) {
          let url = this.playurl.rtsp_url
          let ocxPlayRes = document.getElementById('VionVideo').StartPlay(url, 0);
          console.log('video Ocx播放rtsp流返回值:', ocxPlayRes);
          if (ocxPlayRes != 0) {
            alert('播放失败!');
          }
        } else {
          let OcxResponse = document.getElementById('VionVideo').StartPlaySip(this.playurl.sip_serv_id, this.playurl.sip_serv_ip,
            this.playurl.sip_serv_port, this.playurl.sip_unid, this.playurl.sip_password, this.playurl.devId, 0)
          console.log('video Ocx播放sip流返回值:', OcxResponse);
          if (OcxResponse != 0 && OcxResponse != 200) {
            alert('播放失败!');
          }
        }
      },
      initocx(){
         VionVideo.Init(0, 'Null', 4);
      },
      downloadOCx() {
        if (navigator.userAgent.indexOf('Trident') > -1) {
          this.axios.get(IP + "/api/v1/device/dlfile", {
              params: {
                file_type: "video_ocx"
              }
            })
            .then(response => {
              location.href = response.data.file_url;
            });
        } else {
          this.$message.error("视频控件加载失败请用IE10及以上版本打开!");
        }
      },
      checkIE() {
        var agent = navigator.userAgent.toLowerCase();
        if (/(msie\s|trident.*rv:)([\w.]+)/.test(agent) && document.documentMode < 10) {
          this.$message.error("IE 版本过低请升级到IE10级以上版本!");
        }
      }
    },
    created() {
      this.checkIE();
    },
  
    mounted() {
      VionVideo.Init(0, 'Null', 4);
      try {
        if (document.getElementById("VionVideo").GetVersion()) {
        }
      } catch (error) {
        this.downloadOCx();
      }
    },
    computed: {
      ...mapState(['ocxstate'])
    },
    watch: {
    
    },
    beforeDestroy: function () {
      if (this.videoplayer.techName_ == "Flash" && this.videoplayer.pause) {
        this.videoplayer.pause();
      }
    }
  };

</script>

<style lang="stylus" scoped>

</style>