yingshiVideo.vue 3.16 KB
<template>
  <div class="videoBox">
    <div id="canvasVideo" style="background: black;width:100%;height:100%"></div>
    <div class="btns" v-if="decoder">
      <el-button type="text" class="scaleBtn" icon="el-icon-plus" @mousedown.native='setControl(8)' @mouseup.native='stopControl(8)'></el-button>
      <el-button type="text" class="scaleBtn" icon="el-icon-minus" @mousedown.native='setControl(9)' @mouseup.native='stopControl(9)'></el-button>
    </div>
  </div>
</template>

<script>
  export default{
    data(){
      return{
        currobj:{},
        decoder:'',
        isEdit:'add'
      }
    },
    methods:{
      dialogInit(url,atoken,isEdit,obj,width,height,dIndex){
        this.currobj = obj;
        this.isEdit = isEdit;
        this.dIndex = dIndex
        this.playerVideo(url,atoken,width,height)
      },
      playerVideo(url,atoken,width,height){
        if(this.decoder){
          let canvasVideo = document.getElementById('canvasVideo')
          canvasVideo.innerHTML = ''
        }
        this.$nextTick(()=>{
          this.decoder = new EZUIKit.EZUIKitPlayer({
            id: "canvasVideo", // 视频容器ID
            accessToken: atoken,
            url: url,
            template: 'theme',//simple - 极简版;standard-标准版;security - 安防版(预览回放);voice-语音版;
            autoplay: true,
            // footer: ['paly','hd','fullScreen','pantile'],
            width: width?width:800,
            height:height?height:500,
          });
          setTimeout(()=>{
            this.decoder.play();
          },1000)
          if(this.isEdit == 'edit'){
            let moveParmas = {
              'platform':this.currobj.platform,
              'deviceSerial':this.currobj.deviceSerial,
              'channelNo':this.currobj.channelNo,
              'index':this.dIndex
            }
            this.$api.videoShopTourReport.getPresetMove(moveParmas).then(data => {
              console.log(data.data)
            })
          }
        })
      },
      setControl(val){
        let parmas = {
          'platform':this.currobj.platform,
          'deviceSerial':this.currobj.deviceSerial,
          'channelNo':this.currobj.channelNo,
          'direction':val,
          'speed':1
        }
        this.$api.videoShopTourReport.ptzStart(parmas).then(data => {
          let result = data.data
          if(result.code !=200){
            this.$message({
              message: result.msg,
              type: 'error'
            });
          }
        })
      },
      stopControl(val){
        let parmas = {
          'platform':this.currobj.platform,
          'deviceSerial':this.currobj.deviceSerial,
          'channelNo':this.currobj.channelNo,
          'direction':val
        }
        this.$api.videoShopTourReport.ptzStop(parmas).then(data => {
          console.log(data)
        })
      },
    }
  }
</script>

<style scoped="scoped" lang="less">
  .videoBox{
    position: relative;
  }
  .btns{
    position: absolute;
    right: 15px;
    bottom: 70px;
    .scaleBtn{
      padding: 0;
      width: 20px;
      height: 20px;
      display: block;
      background-color: #fff;
      color: #000;
      margin: 0 0 10px 0;
    }
  }
</style>