海康播放监控

播放h265流解决方案

文中代码:https://github.com/moxiefxj/video_vue

1. 视频WEB插件

  • 视频WEB插件,下载的压缩包中含有播放监控所需要的插件、开发的demo等。
  • 在项目中具体的实现(以vue组件实现为例)
<template>
  <!--视频窗口展示-->
  <div :id="id"></div>
</template>
<script>
export default {
   
  name: "hkVideo",
  data() {
   
    return {
   
      // 视频播放
      initCount: 0, // 初始化重试次数,3次失败则报错
      oWebControl: null, // 页面控制对象
      pubKey: "",
      cameraIp: "xxx.xxx.xx.xx", // 综合安防管理平台IP地址
    };
  },
  props: ["code", "id"], // 接收父页面传来的摄像头 code
  methods: {
   
    // 创建播放实例
    initPlugin() {
   
      // 初始化播放插件
      const _this = this;
      _this.oWebControl = new WebControl({
   
        szPluginContainer: _this.id, // 指定容器id
        iServicePortStart: 15900, // 指定起止端口号,建议使用该值
        iServicePortEnd: 15909,
        szClassId: "23BF3B0A-2C56-4D97-9C03-0CB103AA8F11", // 用于IE10使用ActiveX的clsid
        cbConnectSuccess: function () {
   
          // 创建WebControl实例成功
          console.log("创建WebControl实例成功");
          _this.oWebControl
            .JS_StartService("window", {
   
              // WebControl实例创建成功后需要启动服务
              dllPath: "./VideoPluginConnect.dll", // 值"./VideoPluginConnect.dll"写死
            })
            .then(
              function () {
   
                // 启动插件服务成功
                console.log("启动插件服务成功");
                _this.oWebControl.JS_SetWindowControlCallback({
   
                  // 设置消息回调
                  cbIntegrationCallBack: _this.cbIntegrationCallBack,
                });
                let divWidth = document.getElementById(_this.id).scrollWidth;
                let divHeight = document.getElementById(_this.id).scrollHeight;
                _this.oWebControl
                  .JS_CreateWnd(_this.id, divWidth, divHeight)
                  .then(function () {
   
                    //JS_CreateWnd创建视频播放窗口,宽高可设定
                    _this.init(); // 创建播放实例成功后初始化
                  });
              },
              function () {
   
                // 启动插件服务失败
              }
            );
        },
        cbConnectError: function () {
   
          // 创建WebControl实例失败
          _this.oWebControl = null;
          console.log("warn,插件未启动,正在尝试启动,请稍候...");
          WebControl.JS_WakeUp("VideoWebPlugin://"); // 程序未启动时执行error函数,采用wakeup来启动程序
          initCount++;
          if
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值