WebSDK_V3.3.0 植入Vue2 项目

这篇具有很好参考价值的文章主要介绍了WebSDK_V3.3.0 植入Vue2 项目。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

1.公司需要展示海康摄像头的预览画面

2.经过我两天的搜索资料加尝试,几种方式

2.1后端转码,前端调接口取太麻烦,对服务器负荷大

2.2 vlc插件对rtsp取流 高版本的各种浏览器不支持了vlc插件

2.3 WEB无插件开发包 V3.2  需要支持websocket,不是所有海康设备都支持,而且要自己去开启这个配置

2.4 WEB3.0控件开发包 V3.0  这个原理和vlc插件一模一样,谁会特意下个低版本谷歌

2.5 WEB3.3控件开发包 V3.3 从海康描述来说,非常适合,然后开始钻研,用了一个三天左右,成功迁移到vue项目,并实现预览,本来还要实现在预览画面上配置smart事件的区域,但是这个画面层级太高,我完全无法在画面上加个canvas,然后在canvas上作图.最终效果如下,切换通道可以切换画面

WebSDK_V3.3.0 植入Vue2 项目,vue.js

海康插件下载地址海康开放平台

1.把压缩包解压后,把

webVideoCtrl.js   
jsVideoPlugin-1.0.0.min.js
jquery-1.7.1.min.js三个文件拷贝到自己项目的src/utils文件夹下,然后你准备在哪个页面做预览效果,就在这个页面引入这三个js文件,webVideoCtrl.js的代码是需要改动的(改动是因为它本身是针对html也就是压缩包那样的结构去做的,现在为了适配我的vue,需要改代码,如果你直接使用原html页面,那本文章就不需要参考,你可以demo文件夹直接放在public下,然后vue中跳转,地址就是/demo/index.html,最终会指向public/demo/index.html,然后把除了画面以外的所有样式都改为不可见,注意不能把多余的登陆预览回放组件删掉,否则会有很多调不通的报错),jsVideoPlugin-1.0.0.min.js的代码不需要改动,jquery-1.7.1.min.js也不需要改动

WebSDK_V3.3.0 植入Vue2 项目,vue.js

这边我为了修改webVideoCtrl.js先用idea打开然后格式化了这个文件,格式化之后,里面会有if else导致的报错 比如if(a) b  else c;把它换行成

if(a) b 

else c  就是如果不用大括号包起来,if和else代码不能在同一行

vue页面代码如下

<template>
  <div class='app-container'>

      <el-form ref='ruleForm' :model='ruleForm' :rules='ruleFormRules' label-width='80px' >
        <el-form-item label='通道' prop='enabled'>
          <template slot-scope="scope">
          <el-select
            v-model="ruleForm.monitorPointId"
            placeholder="请选择通道"
            filterable
            size="small"
            @change="regetRule"
          >
            <el-option
              v-for="cameraChannel in points"
              :key="cameraChannel.id"
              :label="cameraChannel.name"
              :value="cameraChannel.id"
            />
          </el-select>
          </template>
        </el-form-item>
        <el-tabs v-model="algorithmId" @tab-click="handleClick">
          <el-tab-pane :label="item.name" :name="item.id" v-for="(item,index) in algorithms" :key="index" ></el-tab-pane>
        </el-tabs>
        <el-form-item label='是否启用' prop='enabled'>
          <el-switch
            v-model="ruleForm.enabled"
            active-color="#13ce66"
            inactive-color="#ff4949">
          </el-switch>
        </el-form-item>
        <el-form-item label='区域规则' class="plugin" prop='coordinates'>
          <div style="position: relative">
            <div id="divPlugin" width="250" height="250" class="plugin"  style="position: relative;top: 0; left: 250px;z-index:-1;pointer-events: none"></div>

               <canvas ref="canvas0" class="plugin"  width="250" height="250" @mousedown="mouseDown" style="pointer-events: none;z-index:3;position: absolute;top: 0; left: 0;background-color: rgba(255, 255, 255, 0.5);border: 1px solid rgb(255, 204, 0);  cursor: default;"></canvas>
          </div>



        </el-form-item>
        <el-form-item label='绘制' prop='screenSize'>
          <el-button type="info" @click="startDraw">开始绘制</el-button>
          <el-button type="info" @click="stopDraw">停止绘制</el-button>
          <el-button type="info" @click="clearDraw">清除绘制</el-button>
        </el-form-item>
        <el-form-item label='目标检测' prop='detectionTarget'>
            <el-checkbox name="human" v-model="humanCheck">人类</el-checkbox>
            <el-checkbox name="vehicle" v-model="vehicleCheck">车辆</el-checkbox>
        </el-form-item>
        <el-form-item label='方向' prop='directionSensitivity' v-if="algCode==='LineDetection'">
          <el-select v-model="ruleForm.directionSensitivity" placeholder="请选择">
            <el-option
              v-for="item in directionList"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label='灵敏度' prop='sensitivityLevel'>
          <el-slider v-model="ruleForm.sensitivityLevel" :min="1" show-input></el-slider>
        </el-form-item>
        <el-form-item label='时间阈值' prop='timeThreshold' v-if="algCode==='FieldDetection'||algCode==='LineDetection'">
          <el-slider v-model="ruleForm.timeThreshold" show-input :max="10"></el-slider>
        </el-form-item>
      </el-form>
      <div slot='footer' class='dialog-footer'>
        <el-button :loading='buttonLoading' type='primary' @click='submitRuleForm'>确 定</el-button>
        <el-button @click='rulecancel'>取 消</el-button>
      </div>
  </div>
</template>

<script>
    import { addByServerIdAndAlgId,addByServerIdAndPointId,deleteByServerIdAndPointId,deleteByServerIdAndAlgId,setRule,addAlgorithmServer, delAlgorithmServer, getAlgorithmServer, listAlgorithmServer, updateAlgorithmServer,getRuleByServerIdAndAlgIdAndPointId } from '@/api/alg/algorithmServer'
    import { listMonitorPointAll } from '@/api/alg/monitorPoint';
    import { listAlgorithmAll } from '@/api/alg/algorithm';
    import $ from '@/utils/webVideoCtrl';
    import a from '@/utils/jsVideoPlugin-1.0.0.min';
    import b from '@/utils/jquery-1.7.1.min';
    import axios from "axios";
export default {
  name: 'smartEvent',
  data() {
    return {
      points:[],
      algorithms:[],
      directionList:[{label:'左->右',value:"left-right"},{label:'左<->右',value:"any"},{label:'左<-右',value:"right-left"}],
      algCode:'',
      humanCheck:false,
      vehicleCheck:false,
      id:null,
      algorithmId:'',
      activeName:0,
      channelFilterValue:'',
      algFilterValue:'',
      AllPointList:[],
      ShowPointList:[],
      AllAlgList:[],
      ShowAlgList:[],
      // 按钮loading
      buttonLoading: false,
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 算法服务器表格数据
      algorithmServerList: [],
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: undefined,
        ip: undefined,
      },

      // 表单参数
      form: {
        id: undefined,
        name: undefined,
        ip: undefined,
        port: undefined,
        username: undefined,
        password: undefined,
        updateTime: undefined,
        createTime: undefined,
        updateBy: undefined,
        createBy: undefined,
        delFlag: undefined,
        algorithms: [],
        points:[],
      },
      actionArr: [],
      ruleForm:{
        sensitivityLevel:50,
        monitorPointId:undefined,
        detectionTarget:undefined,
        screenSize: undefined,
        timeThreshold: 5,
        coordinates: undefined,
        enabled:false
      },
      drawFlag:false,
      openRule:false,
      ruleFormRules:{
        monitorPointId: [
          { required: true, message: '通道不能为空', trigger: 'blur' }
        ],

      },
      // 表单校验
      rules: {
        id: [
          { required: true, message: '不能为空', trigger: 'blur' }
        ],
        name: [
          { required: true, message: '名称不能为空', trigger: 'blur' }
        ],
        ip: [
          { required: true, message: 'ip不能为空', trigger: 'blur' }
        ],
        port: [
          { required: true, message: 'port不能为空', trigger: 'blur' }
        ],
        username: [
          { required: true, message: '账号不能为空', trigger: 'blur' }
        ],
        password: [
          { required: true, message: '密码不能为空', trigger: 'blur' }
        ],
      }
    }
  },
  created() {



  },
  destroyed(){
    WebVideoCtrl.I_DestroyPlugin();
  },
  mounted(){
    this.serverId=this.$route.query.serverId;
    getAlgorithmServer({id:this.serverId}).then((res)=>{
      this.points=res.data.points;
      this.algorithms=res.data.algorithms;
      if (res.data.points.length!=0){
        this.ruleForm.monitorPointId=res.data.points[0].id;
      }
      if(res.data.algorithms.length!=0){
        this.algorithmId=res.data.algorithms[0].id;
      }
      this.$forceUpdate;
      WebVideoCtrl.I_InitPlugin({
        bWndFull: false,     //是否支持单窗口双击全屏,默认支持 true:支持 false:不支持
        iWndowType: 1,
        bDebugMode: true,
        cbInitPluginComplete: function () {
          WebVideoCtrl.I_InsertOBJECTPlugin("divPlugin").then(() => {
            console.log("插件初始化")
            // 检查插件是否最新
            WebVideoCtrl.I_CheckPluginVersion().then((bFlag) => {
              if (bFlag) {
                alert("检测到新的插件版本,双击开发包目录里的HCWebSDKPlugin.exe升级!");
              }
            });


          }, () => {
            alert("插件初始化失败,请确认是否已安装插件;如果未安装,请双击开发包目录里的HCWebSDKPlugin.exe安装!");
            axios.get('/file/HCWebSDKPlugin.exe',{
              responseType: 'blob'
            }).then(res => {
              console.log(res);
              const url = window.URL.createObjectURL(new Blob([res.data]));
              const link = document.createElement('a');
              link.href = url;
              link.setAttribute('download', 'HCWebSDKPlugin.exe');
              document.body.appendChild(link);
              link.click();
            })
          });
        }
      });

      if (this.algorithmId&&this.ruleForm.monitorPointId){
        console.log("预览初始化")
        this.getRule();
      };
    })



  },
  methods: {
    handleClick(tab, event){
      for(let i =0;i<this.algorithms.length;i++){
        let item=this.algorithms[i];
        if (item.id==this.algorithmId){
          this.algCode=item.code;
          break;
        }
      }
    this.getRule();
    },
    startDraw(){
      console.log("开启绘制")
      this.drawFlag=true;
     // this.rtsp();
    },
    clearDraw(){
      const canvasDraw0 = this.$refs.canvas0;
      const ctx=canvasDraw0.getContext('2d');
      ctx.clearRect(0, 0, canvasDraw0.width, canvasDraw0.height);
      this.actionArr=[];
    },
    stopDraw(){
      if (this.drawFlag){
        console.log(this.actionArr);
        console.log(this.algCode);
        if(this.actionArr.length!==2&&this.algCode==='LineDetection'){
          alert("越界告警需要两个坐标");
          return;
        }else if(this.actionArr.length!==4&&this.algCode!=='LineDetection'){
          alert("区域需要四个坐标点");
          return;
        }

      }
      this.drawFlag=false;
    },
    drawCircle(x, y){

    },
    mouseDown(e){
      console.log(e);
      if(e.buttons==1&&this.drawFlag){
        if(this.actionArr.length>=4){
          return;
        }
        this.actionArr.push({x:e.offsetX,y:e.offsetY})
        this.drawActionArr();
      }

    },
    mouseMove(e){
      console.log(e);
    },

    filterAlg(){
      this.ShowAlgList=this.AllAlgList.filter(function (element,index,array){
        return element.name.search(e)!=-1;
      })
    },
    filterChannel(e){
      this.ShowPointList=this.AllPointList.filter(function (element,index,array){
        return element.name.search(e)!=-1;
      })
    },
    handleAlgAdd(index){
      let element = this.ShowAlgList[index];
      let find=this.form.algorithms.find((value => value.id==element.id));
      if (!find){
        addByServerIdAndAlgId({algorithmId:element.id,serverId:this.id}).then(response=>{
          this.form.algorithms.push(element);
        })
      }
    },
    handleChannelAdd(index){
      let element = this.ShowPointList[index];
      let find=this.form.points.find((value => value.id==element.id));
      if (!find){
        addByServerIdAndPointId({pointId:element.id,serverId:this.id}).then(response=>{
        this.form.points.push(element);
        })
      }
    },
    drawActionArr(){
      if (this.actionArr.length>0){
        const canvasDraw0 = this.$refs.canvas0;
        const ctx=canvasDraw0.getContext('2d');
        ctx.fillStyle="black";
        ctx.clearRect(0, 0, canvasDraw0.width, canvasDraw0.height)
        for (let i = 0; i <this.actionArr.length ; i++) {

          ctx.beginPath();
          ctx.arc(this.actionArr[i].x,this.actionArr[i].y,5,0,2*Math.PI,true);
          ctx.fill();
          ctx.closePath();
          ctx.font="20px Georgia";
          ctx.fillText(i+1,this.actionArr[i].x,this.actionArr[i].y)
        }

        ctx.beginPath();
        ctx.moveTo(this.actionArr[0].x,this.actionArr[0].y);
        for (let i = 1; i <this.actionArr.length ; i++) {
          ctx.lineTo(this.actionArr[i].x,this.actionArr[i].y);
          ctx.moveTo(this.actionArr[i].x,this.actionArr[i].y);
          if (i==this.actionArr.length-1){
            ctx.lineTo(this.actionArr[0].x,this.actionArr[0].y);
          }
        }
        ctx.stroke()
        ctx.closePath();
      }
    },
    regetRule(e){
      this.getRule();
    },
    getRule(){

      getRuleByServerIdAndAlgIdAndPointId({serverId:this.serverId,algorithmId:this.algorithmId,pointId:this.ruleForm.monitorPointId}).then(response => {
        this.clearDraw();
        this.humanCheck=false;
        this.vehicleCheck=false;
        if (response.data){
          this.ruleForm = response.data;
          this.actionArr=this.ruleForm.coordinates?this.ruleForm.coordinates.map(function(value) {
            return {x:parseInt(value.x)/4,y:parseInt(value.y)/4}
          }):[];
          this.drawActionArr();
          if (response.data.detectionTarget) {
            if (response.data.detectionTarget === 'human') {
              this.humanCheck = true;
              this.vehicleCheck = false;
            } else if (response.data.detectionTarget === 'vehicle') {
              this.humanCheck = false;
              this.vehicleCheck = true;
            } else if (response.data.detectionTarget === 'human,vehicle') {
              this.humanCheck = true;
              this.vehicleCheck = true;
            }
          }
          this.$forceUpdate();
          console.log("ruleForm")
          console.log(this.ruleForm)
          this.startView(response.data.point);


        }else {
          console.log("没返回值")
          this.ruleForm ={
            monitorPointId:this.ruleForm.monitorPointId,
            serverId:this.serverId,
            algorithmId:this.algorithmId,
            sensitivityLevel:50,
            detectionTarget:undefined,
            screenSize: undefined,
            timeThreshold: 5,
            coordinates: undefined,
            enabled:false
          };
        }

      });
    },

    startView(option){
      console.log("走到预览方法里")
      if (!option||!option.username||!option.password||!option.ip){
        alert("监控点数据不全,无法预览")
        return;
      }
      //获取预览画面
      var oLiveView = {
        iProtocol: 1,            // protocol 1:http, 2:https
        szIP: option.ip,    // protocol ip
        szPort: "80",            // protocol port
        szUsername: option.username,     // device username
        szPassword: option.password, // device password
        iStreamType: 1,          // stream 1:main stream  2:sub-stream  3:third stream  4:transcode stream
        iChannelID: option.channelId?option.channelId:1,           // channel no
        bZeroChannel: false      // zero channel
      };
      let isExists = WebVideoCtrl.findDeviceIndexByIP(option.ip);
      console.log("是否登陆过")
      console.log(isExists!==-1)
      if (isExists!==-1){
        var szDeviceIdentify = oLiveView.szIP + "_" + oLiveView.szPort;
        var oWndInfo = WebVideoCtrl.I_GetWindowStatus(0);
        console.log("窗口是否在播放")
        console.log(oWndInfo != null)
        if (oWndInfo != null) {// 已经在播放了,先停止
          WebVideoCtrl.I_Stop({iWndIndex:0,
            success: function () {
            console.log("停止成功")
              setTimeout(function () {
                WebVideoCtrl.I_StartRealPlay(szDeviceIdentify, {
                  iWndIndex:0,
                  iStreamType: oLiveView.iStreamType,
                  iChannelID: oLiveView.iChannelID,
                  bZeroChannel: oLiveView.bZeroChannel
                });
              }, 1000);
            }
          });
        } else {
          setTimeout(function () {
            WebVideoCtrl.I_StartRealPlay(szDeviceIdentify, {
              iWndIndex:0,
              iStreamType: oLiveView.iStreamType,
              iChannelID: oLiveView.iChannelID,
              bZeroChannel: oLiveView.bZeroChannel
            });
          }, 1000);
        }
        return;
      }

      WebVideoCtrl.I_Login(oLiveView.szIP, oLiveView.iProtocol, oLiveView.szPort, oLiveView.szUsername, oLiveView.szPassword, {
        success: function (xmlDoc) {
          console.log("登陆成功")
          // 开始预览
          var szDeviceIdentify = oLiveView.szIP + "_" + oLiveView.szPort;
          var oWndInfo = WebVideoCtrl.I_GetWindowStatus(0);
          console.log("窗口是否在播放")
          console.log(oWndInfo != null)
          if (oWndInfo != null) {// 已经在播放了,先停止
            WebVideoCtrl.I_Stop({iWndIndex:0,
              success: function () {
                console.log("停止播放")
                setTimeout(function () {
                  WebVideoCtrl.I_StartRealPlay(szDeviceIdentify, {
                    iWndIndex:0,
                    iStreamType: oLiveView.iStreamType,
                    iChannelID: oLiveView.iChannelID,
                    bZeroChannel: oLiveView.bZeroChannel
                  });
                }, 1000);
              }
            });
          } else {
            setTimeout(function () {
              WebVideoCtrl.I_StartRealPlay(szDeviceIdentify, {
                iWndIndex:0,
                iStreamType: oLiveView.iStreamType,
                iChannelID: oLiveView.iChannelID,
                bZeroChannel: oLiveView.bZeroChannel
              });
            }, 1000);
          }

        },
        error: function (oError) {
        if (2001 === status) {
          var szDeviceIdentify = oLiveView.szIP + "_" + oLiveView.szPort;
          var oWndInfo = WebVideoCtrl.I_GetWindowStatus(0);
          if (oWndInfo != null) {// 已经在播放了,先停止
            WebVideoCtrl.I_Stop({iWndIndex:0,
              success: function () {
                console.log("停止播放成功")
                setTimeout(function () {
                  WebVideoCtrl.I_StartRealPlay(szDeviceIdentify, {
                    iWndIndex:0,
                    iStreamType: oLiveView.iStreamType,
                    iChannelID: oLiveView.iChannelID,
                    bZeroChannel: oLiveView.bZeroChannel,
                  });
                }, 1000);
              }
            });
          } else {
            setTimeout(function () {
              WebVideoCtrl.I_StartRealPlay(szDeviceIdentify, {
                iWndIndex:0,
                iStreamType: oLiveView.iStreamType,
                iChannelID: oLiveView.iChannelID,
                bZeroChannel: oLiveView.bZeroChannel
              });
            }, 1000);
          }
        }else {
          console.log("登陆失败")
          console.log(oLiveView)
          console.log(oError);
          console.log(status);
        }
      }
      });
    },
    handleAlgRemove(index){
      this.form.algorithms.splice(index,1);
    },
    handlePointRemove(index){
      this.form.points.splice(index,1);
    },
    showPointers(row){
      this.algCode=row.code?row.code:"";
      this.algorithmId=row.id;
      this.openRule=true;
      this.rulereset();

    },

    // 取消按钮
    cancel() {
      this.open = false
      this.reset()
    },
    // 取消按钮
    rulecancel() {
      this.rulereset()
      this.openRule = false
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        name: undefined,
        ip: undefined,
        port: undefined,
        username: undefined,
        password: undefined,
        updateTime: undefined,
        createTime: undefined,
        updateBy: undefined,
        createBy: undefined,
        delFlag: undefined,
        algorithms: [],
        points:[],
      }
      this.resetForm('form')
    },
    rulereset() {
      this.ruleForm = {
        sensitivityLevel:50,
        monitorPointId:undefined,
        detectionTarget:undefined,
        screenSize: undefined,
        timeThreshold: 5,
        coordinates: undefined,
        enabled:false
      }
      this.clearDraw();
      this.resetForm('ruleForm')
    },

    /** 修改按钮操作 */
    handleUpdate(row) {
      this.id=row.id;
      this.loading = true
      this.reset()
      const id = row.id || this.ids
      getAlgorithmServer({ id: id }).then(response => {
        this.loading = false
        this.form = response.data
        this.open = true
        this.title = '修改算法服务器'
      })
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs['form'].validate(valid => {
        if (valid) {
          this.buttonLoading = true
          if (this.form.id != null) {
            updateAlgorithmServer(this.form).then(response => {
              this.$modal.msgSuccess('修改成功')
              this.open = false
              this.getList()
            }).finally(() => {
              this.buttonLoading = false
            })
          } else {
            addAlgorithmServer(this.form).then(response => {
              this.$modal.msgSuccess('新增成功')
              this.open = false
              this.getList()
            }).finally(() => {
              this.buttonLoading = false
            })
          }
        }
      })
    },
    submitRuleForm() {
      if(this.drawFlag){
        alert("请先完成绘制");
        return;
      }
      this.$refs['ruleForm'].validate(valid => {
        if (valid) {
          this.buttonLoading = true
            if (!this.humanCheck&&!this.vehicleCheck){
              this.ruleForm.detectionTarget='all'
            } else if(this.humanCheck&&!this.vehicleCheck){
              this.ruleForm.detectionTarget='human'
            }else if(!this.humanCheck&&this.vehicleCheck){
              this.ruleForm.detectionTarget='vehicle'
            }else {
              this.ruleForm.detectionTarget='human,vehicle'
            }
            if (this.actionArr.length!==0){
              this.ruleForm.coordinates= this.actionArr.map(function(value) {
                return {x:4*value.x,y:4*value.y}
              })
            }
            setRule(this.ruleForm).then(response => {
              this.$modal.msgSuccess('新增成功')
              this.openRule = false
              this.getList()
            }).finally(() => {
              this.buttonLoading = false
            })

        }
      })
    },


    /** 导出按钮操作 */
    handleExport() {
        this.$download.excel('/alg/algorithmServer/export', this.queryParams)
    }
  }
}
</script>
<style scoped>
.hide {
  display: none;
}
.item {
  height: 30px;
  line-height: 30px;
  margin: 0 15px;
}
.plugin {
  width: 250px;
  height: 250px;
}
.channel-list {
  max-height: 660px;
  overflow: scroll;
}

::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  width: 6px;
  background: none;
  -webkit-border-radius: 2em;
  -moz-border-radius: 2em;
  border-radius: 2em;
}

::-webkit-scrollbar-thumb {
  background-color: rgba(144, 147, 153, .5);
  background-clip: padding-box;
  min-height: 28px;
  -webkit-border-radius: 2em;
  -moz-border-radius: 2em;
  border-radius: 2em;
  transition: background-color .3s;
  cursor: pointer;
}

::-webkit-scrollbar-thumb:hover {
  background-color: rgba(144, 147, 153, .3);
}
.view {
  min-width: 1120px;
  padding: 10px 15px;
}
</style>

webVideoCtrl.js主要修改初始化插件的代码,原先有个获取dirName方法就是获取webVideoCtrl.js自己的文件路径前缀,通过这个路径拼接再去找到jsVideoPlugin.js,但是vue结构下打包后这个文件路径获取肯定不对,所有我把webVideoCtrl.js和jsVideoPlugin.js放到utils里,然后通过require([./xxx.js])的方法在webVideoCtrl.js中引入jsVideoPlugin.js,注意它是把整个jsVideoPlugin.js存到了自身的window.JSvideoPlugin变量中,方便之后调用,然后它这边还有个值得注意的是窗口号,因为我只需要单窗口,所有我的窗口号传的都0;文章来源地址https://www.toymoban.com/news/detail-756024.html

this.I_InitPlugin = function(options) {
      m_utilsInc.extend(m_options, options)
     
     
        if ('object' === typeof exports && typeof module !== 'undefined') {
          require([ './jsVideoPlugin-1.0.0.min.js'], function(o) {
            window.JSVideoPlugin = o.JSVideoPlugin
            if (options.cbInitPluginComplete) {
              options.cbInitPluginComplete()
            }
          })
        } else if ('function' === typeof define && define.amd) {
          require([ './jsVideoPlugin-1.0.0.min.js'], function(o) {
            window.JSVideoPlugin = o.JSVideoPlugin
            if (options.cbInitPluginComplete) {
              options.cbInitPluginComplete()
            }
          })
        } else {
          m_utilsInc.loadScript( './jsVideoPlugin-1.0.0.min.js', function() {
            if (options.cbInitPluginComplete) {
              options.cbInitPluginComplete()
            }
          })
        }
    
      window.addEventListener('resize', function() {
        if (m_pluginOBJECT !== null) {
          var oElem = $('#' + m_options.szContainerID)
          m_pluginOBJECT.JS_Resize(oElem.width(), oElem.height())
        }
      })
      window.addEventListener('unload', function() {
      })
      window.addEventListener('scroll', function() {
      })
    }

到了这里,关于WebSDK_V3.3.0 植入Vue2 项目的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • vue2.x项目没有vue.config.js时,web worker使用

    vue:2.7.14,webpack 3.6.0构建项目 在vue中使用new Worker(‘./worker.js’)原生方法,引入woker.js子线程时,无法正常读取引入。于是乎就百度了一下,网上vue使用web worker的步骤。 1.安装使用 worker-loader // 安装依赖包 npm install worker-loader -D 2.vue.config.js 完整配置 module.exports = { chainWebpac

    2024年02月06日
    浏览(53)
  • node.js版本过高,导致vue2 版本的项目无法正常启动

    node.js版本过高,导致vue2 版本的项目无法正常启动 node的版本是18 ,vue版本是2 ;npm install 失败 1、未采取提示的方式,而是利用了npx命令; 使用npx指定npm的版本 npx -p npm@6 npm i --legacy-peer-deps 注意:如果这不能立即起作用,也许可以先删除node_modules和package-lock.json。它们将被重

    2024年02月08日
    浏览(49)
  • 【Vue】Vue2创建移动端项目实战教程,创建移动端项目保姆级教程,设置axios,utils工具包,vue.fonfig.js配置项 (下)

    这里是创建移动端项目 【Vue】Vue2.x创建项目全程讲解,保姆级教程,手把手教,Vue2怎么创建项目(上) 【Vue】Vue2创建移动端项目实战教程,创建移动端项目保姆级教程,接上一篇创建Vue2项目(中) 【Vue】Vue2创建移动端项目实战教程,创建移动端项目保姆级教程,设置ax

    2024年02月13日
    浏览(37)
  • Rspack 创建 vue2/3 项目接入 antdv(rspack.config.js 配置 less 主题)

    Rspack CLI 官方文档。 rspack.config.js 官方文档。 创建项目(文档中还提供了 Rspack 内置 monorepo 框架 Nx 的创建方式,根据需求进行选择) 创建好项目并运行,目前 Rspack 版本支持的工程模版: 默认创建的 vue 项目为 vue3 : 如果需要其他版本,或其他框架的基础工程,可到官方提

    2024年02月11日
    浏览(40)
  • vue2 若依项目,使用plotly.js-dist图表库,将数据图表一键导出为图片

    此代码适用的场景是一个页面有多个数据图表。 首先需要拿到你生成数据图表的数据, 然后赋值给一个数组,数组需要在data定义,还需要去重。  然后点击导出按钮的代码如下: 单个下载可以点击数据图表的照相机,可以实现单个下载。 如果数据图表做了分页和懒加载,无

    2024年02月12日
    浏览(37)
  • 前端(四)——vue.js、vue、vue2、vue3

    😊博主:小猫娃来啦 😊文章核心: vue.js、vue、vue2、vue3从全局到局部 Vue.js是一款流行的JavaScript框架 vue,vue2,vue3都是vue.js的不同版本。 Vue:Vue.js的第一个版本,也称为Vue 1.x。它于2014年首次发布,并获得了广泛的应用和认可。 Vue2:Vue.js的第二个版本,也称为Vue 2.x。它在Vu

    2024年02月12日
    浏览(47)
  • Vue2 系列:vue.config.js 参数配置

    1. publicPath 默认值:\\\'/\\\' 说明:部署应用包时的基本 URL,例:https://www.my-app.com/my-app/,则设置 publicPath 为 /my-app/ 提示:1. 当使用基于 HTML5 history.pushState 的路由时 2.当使用 pages 选项构建多页面应用时。 2. outputDir 默认值:\\\'dist\\\' 说明:打包目录。 提示:目标目录在构建之前会被

    2024年02月11日
    浏览(43)
  • 【Vue2】引入本地原生JS文件

    日常开发的时候,第一个想法肯定是找现有的插件进行开发,在项目中npm install xxx 插件即可。但是也有无法使用的插件的情况,就需要我们引用我们本地的原生js。 自己写的文件或者别人的插件都可以通过下面的方式修改成vue能够识别的js。 字符操作文件 utils/str.js  在函数

    2024年02月16日
    浏览(33)
  • uniapp引入全局js,vue2/vue3不同方式引入

    Hi I’m Shendi uniapp引入全局js,vue2/vue3不同方式引入 最近写小程序,个人开发,选用了 uni-app 进行开发 选用的 vue3 版本 因为我用的 vue3 版本,在这里踩了没学过vue3的坑,用vue2引入全局js的方式使用,导致undefined… Vue2 版引入全局js的方法如下 将js放到项目内,一般放到自建的

    2024年02月03日
    浏览(30)
  • vue2的vue.config.js中简单配置代理跨域

    调用后端接口访问后台数据,但是因为请求url的协议、域名、端口三者之间任意一个与当前页面url不同产生了跨域,我们vue项目运行的地址一般就是localhost 8080端口,而且后端也没有配置允许跨域(后端如果配置跨域通常是cors),所以前端就要配置跨域,Vue跨域在vue.config.j

    2024年02月15日
    浏览(29)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包