vue对接海康摄像头-H5player

1.在public中放入js

📎H5播放器功能性能说明.xlsx

视口大小

css 复制代码
init() {
  // 设置播放容器的宽高并监听窗口大小变化
  window.addEventListener("resize", () => {
    this.player.JS_Resize();
  });
},
// 媒体查询设置窗口的大小
@media screen and (max-width: 1990px) {
  #player {
    width: calc(100vw - 16px);
    height: calc((90vw - 16px) * 5 / 8);
  }
  #control {
    width: calc(100vw - 10px);
    height: 50px;
    margin-top: -3px;
    position: relative;
    z-index: 1;
    background-color: rgb(62, 61, 66, 0.8);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
  }
}

@media screen and (min-width: 750px) {
  #player {
    width: calc(70vw - 8px);
    height: calc((70vw - 8px) * 5 / 8);
  }
  #control {
    width: calc(70vw - 10px);
    height: 50px;
    background-color: rgb(62, 61, 66, 0.8);
    margin-top: -3px;
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
  }
}

监控点树形列表

ini 复制代码
 // 查询区域列表v2
    getNodesByParams() {
      this.forwardParams.requestMethod = "post";
      this.forwardParams.url =
        process.env.VUE_APP_BASE_URL + "/api/irds/v2/region/nodesByParams";
      this.forwardParams.paramType = "body";
      this.forwardParams.params = {
        resourceType: "camera",
        pageNo: "1",
        pageSize: "100",
      };
      getHik(this.forwardParams).then((res) => {
        const jsonStr = res.data;
        const data = JSON.parse(jsonStr);
        console.log("区域列表", data.data.list);
        const nodeList = data.data.list;
        this.getCameraOnline(nodeList);
      });
    },

    // 获取监控点列表
    getCameraOnline(nodeList) {
      this.forwardParams.requestMethod = "post";
      this.forwardParams.url =
        process.env.VUE_APP_BASE_URL + "/api/resource/v2/camera/search";
      this.forwardParams.paramType = "body";
      this.forwardParams.params = {
        pageNo: "1",
        pageSize: "100",
      };
      getHik(this.forwardParams).then((res) => {
        const jsonStr = res.data;
        const data = JSON.parse(jsonStr);
        if (data.data) {
          // console.log("视频列表", data.data.list);
          const cameraList = data.data.list;

          const newCodeArray = cameraList.map((camera) => ({
            name: camera.name,
            parentIndexCode: camera.regionIndexCode,
            indexCode: camera.indexCode,
            cameraType: camera.cameraType,
          }));

          const tree = [...newCodeArray, ...nodeList];
          this.treeData = this.handleTree(tree, "indexCode", "parentIndexCode");
          // console.log("treeData", this.treeData);
        }
      });
    },

获取视频流

kotlin 复制代码
 handleNodeClick(data) {
       this.count++;
      
      if (this.count % 2 === 0) {
        // 偶数次点击的逻辑
        console.log('偶数次点击');
         console.log("data", data);
        // 球机弹出云台控制卡片
      if (data.cameraType === 2) {
        this.allowClick = true;
        this.customTreeStyle.minHeight = "55%";
      } else {
        this.allowClick = false;
        this.customTreeStyle.minHeight = "95%";
      }
      //码流类型,0:主码流 1:子码流 2:第三码流 参数不填,默认为主码流
      if (this.splitNum === 3) {
        this.streamType = 1;
      } else {
        this.streamType = 0;
      }

      this.cameraIndexCode = data.indexCode;
      this.forwardParams.requestMethod = "post";
      this.forwardParams.url =
        process.env.VUE_APP_BASE_URL + "/api/video/v2/cameras/previewURLs";
      this.forwardParams.paramType = "body";
      this.forwardParams.params = {
        cameraIndexCode: data.indexCode,
        streamType: this.streamType,
        protocol: "ws",
        transmode: 1,
        expand: "transcode=0",
        streamform: "ps",
      };
      getHik(this.forwardParams).then((res) => {
        const jsonStr = res.data;
        const data = JSON.parse(jsonStr);
        console.log("视频流", data.data.url);
        const url = data.data.url;
        this.urls.realplay = url;
        this.realplay(); // 预览视频方法
      });
      }
     
    },

云台控制

ini 复制代码
 // 云台操作
    controlling(command) {

      this.forwardParams.requestMethod = "post";
      this.forwardParams.url =
        process.env.VUE_APP_BASE_URL + "/api/video/v1/ptzs/controlling";
      this.forwardParams.paramType = "body";
      this.forwardParams.params = {
        cameraIndexCode: this.cameraIndexCode,
        action: 0,
        command: command,
        presetIndex: 20,
      };
      getHik(this.forwardParams).then((res) => {
        const jsonStr = res.data;
        const data = JSON.parse(jsonStr);
        console.log("云台操作", data.msg);
      });
    },

分屏暂停切窗口 文档中写

相关推荐
程序员小易6 分钟前
前端轮子(2)--diy响应数据
前端·javascript·浏览器
前天的五花肉6 分钟前
D3.js研发Biplot(代谢)图
前端·javascript·css
oh,huoyuyan12 分钟前
【实用技巧】火语言RPA:界面『日期时间』控件,实现网页日期自动填写
前端·javascript·rpa
程序员小寒12 分钟前
前端性能优化之Webpack篇
前端·webpack·性能优化
谢尔登12 分钟前
React的Fiber架构
前端·react.js·架构
我是华为OD~HR~栗栗呀15 分钟前
(华为od)21届-Python面经
java·前端·c++·python·华为od·华为·面试
刘一说27 分钟前
ES6+核心特性全面浅析
java·前端·es6
kirinlau34 分钟前
Vue.observable实现vue原生轻量级状态管理详解
前端·javascript·vue.js
严文文-Chris35 分钟前
RAG关键技术要点详解
java·服务器·前端
自然 醒35 分钟前
elementUI的select下拉框如何下拉加载数据?
前端·javascript·elementui