在web页面使用webVideoCtrl.js集成海康威视

您所在的位置:网站首页 海康威视web插件一直提示安装异常 在web页面使用webVideoCtrl.js集成海康威视

在web页面使用webVideoCtrl.js集成海康威视

2024-06-14 18:17| 来源: 网络整理| 查看: 265

项目场景:

使用的是webSDK3.3版本的集成包,在项目上接入海康威视的视频

问题描述

1.在初始化成功后想去调用登录接口,结果一直报错,如图1-1 2.在两个页面都接入海康威视的视频时,两个页面做切换会报错,导致页面没有被销毁,如图1-2

在这里插入图片描述 图1-1 图2-1 图1-2 在这里插入图片描述

原因分析:

问题1:登录报错是因为用到了websocket,用异步方式去登陆会报错,只能使用同步方式,所以在初始化里面登录,

initVideoPlay(iWndowType) { let that=this WebVideoCtrl.I_InitPlugin({ bWndFull: true, //是否支持单窗口双击全屏,默认支持 true:支持 false:不支持 iWndowType:2, cbSelWnd: function (xmlDoc) { g_iWndIndex = parseInt($(xmlDoc).find("SelectWnd").eq(0).text(), 10); let szInfo = "当前选择的窗口编号:" + that.g_iWndIndex; console.log(szInfo); }, cbDoubleClickWnd: function (iWndIndex, bFullScreen) { let szInfo = "当前放大的窗口编号:" + iWndIndex; if (!bFullScreen) { szInfo = "当前还原的窗口编号:" + iWndIndex; } console.log(szInfo); }, cbEvent: function (iEventType, iParam1, iParam2) { if (2 == iEventType) {// 回放正常结束 } else if (-1 == iEventType) { console.log("设备" + iParam1 + "网络错误!"); } else if (3001 == iEventType) { clickStopRecord(g_szRecordType, iParam1); } }, cbInitPluginComplete: function () { WebVideoCtrl.I_InsertOBJECTPlugin("trafficPlugin").then(() => { that.szDeviceIdentify = that.hkvInfo.ip + "_" + that.hkvInfo.port; if(that.isLogin ==false) { let szIP = that.hkvInfo.ip, szPort = that.hkvInfo.port, szUsername = that.hkvInfo.username, szPassword = that.hkvInfo.password; if ("" == szIP || "" == szPort) { return; } let iRet = WebVideoCtrl.I_Login(szIP, 1, szPort, szUsername, szPassword, { timeout: 3000, success: function (xmlDoc) { //console.log(that.szDeviceIdentify + " 登录成功!") that.ifShow = true that.isLogin=true setTimeout(function () { setTimeout(function () { that.getChannelInfo();//获取通道号 }, 1000); that.getDevicePort(); }, 10); }, error: function (oError) { if(oError.errorCode==2001){ that.clickStartRealPlay() }else { console.log('登录失败'); } } }); }else { //直接预览 that.getChannelInfo();//获取通道号 } // 检查插件是否最新 WebVideoCtrl.I_CheckPluginVersion().then((bFlag) => { if (bFlag) { alert("检测到新的插件版本,双击开发包目录里的HCWebSDKPlugin.exe升级!"); } }); }, () => { alert("插件初始化失败,请确认是否已安装插件;如果未安装,请双击开发包目录里的HCWebSDKPlugin.exe安装!"); }); } }); },

问题2:两个视频页面直接快速切换,视频销毁也要一点时间,我目前是先切换到其他页面再切换到另一个视频页面,要是大家有什么好的建议可以给我留下评论

#停止正在播放的页面 clickStopRealPlay() { let self = this let oWndInfo = WebVideoCtrl.I_GetWindowStatus(self.g_iWndIndex), szInfo = ""; if (oWndInfo != null) { WebVideoCtrl.I_StopAllPlay();//停止正在播放的页面 setTimeout(() => { WebVideoCtrl.I_DestroyPlugin() }, 2000); } },


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3