html调用内网海康威视摄像头
我的需求很简单就是在html的主页上用iframe加载出摄像头,海康威视的摄像头无法直接调用,必须安装海康提供的web插件包,使用插件的demo是可以调用的,但是单独搞出来又无法使用,所以直接在原来的demo里加入js,使他自行加载以来显示页面,显示出来就可以进行iframe了。

html:

<!doctype html>
<html>
<head><title></title><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta http-equiv="Pragma" content="no-cache" /><meta http-equiv="Cache-Control" content="no-cache, must-revalidate" /><meta http-equiv="Expires" content="0" /><script>document.write("<link type='text/css' href='demo.css?version=" + new Date().getTime() + "' rel='stylesheet' />");</script>
</head>
<body>
<div class="left"><div id="divPlugin" class="plugin"></div><fieldset class="ipparse"><legend>设备IP解析</legend><table cellpadding="0" cellspacing="3" border="0"><tr><td class="tt">模式</td><td colspan="3"><select id="devicemode" class="sel" onchange="changeIPMode(this.value);"><option value="1">IPServer</option><option value="2">HiDDNS</option></select></td></tr><tr><td class="tt">服务器地址</td><td><input id="serveraddress" type="text" class="txt" value="" /></td><td class="tt">端口号</td><td><input id="serverport" type="text" class="txt" value="7071" /></td></tr><tr><td class="tt">设备标识</td><td><input id="deviceid" type="text" class="txt" value="" /></td><td class="tt">&nbsp;</td><td><input type="button" class="btn" value="获取设备IP" onclick="clickGetDeviceIP();" /></td></tr></table></fieldset><fieldset class="login"><legend>登录</legend><table cellpadding="0" cellspacing="3" border="0"><tr><td class="tt">IP地址</td><td><input id="loginip" type="text" class="txt" value="172.9.4.222" /></td><td class="tt">端口号</td><td><input id="port" type="text" class="txt" value="80" /></td></tr><tr><td class="tt">用户名</td><td><input id="username" type="text" class="txt" value="admin" /></td><td class="tt">密码</td><td><input id="password" type="password" class="txt" value="12345" /></td></tr><tr><td class="tt">设备端口</td><td colspan="2"><input id="deviceport" type="text" class="txt" value="8000" />(可选参数)</td><td>窗口分割数&nbsp;<select class="sel2" onchange="changeWndNum(this.value);"><option value="1">1x1</option><option value="2" selected>2x2</option><option value="3">3x3</option><option value="4">4x4</option></select></td></tr><tr><td colspan="4"><input type="button" class="btn" value="登录" onclick="clickLogin();" /><input type="button" class="btn" value="退出" onclick="clickLogout();" /><input type="button" class="btn2" value="获取基本信息" onclick="clickGetDeviceInfo();" /></td></tr><tr><td class="tt">已登录设备</td><td><select id="ip" class="sel" onchange="getChannelInfo();"></select></td><td class="tt">通道列表</td><td><select id="channels" class="sel"></select></td></tr></table></fieldset><fieldset class="ipchannel"><legend>数字通道</legend><table width="100%" cellpadding="0" cellspacing="3" border="0"><tr><td><input type="button" class="btn" value="获取数字通道列表" onclick="clickGetDigitalChannelInfo();" /></td></tr><tr><td><div class="digitaltdiv"><table id="digitalchannellist" class="digitalchannellist" cellpadding="0" cellspacing="0" border="0"></table></div></td></tr></table></fieldset><fieldset class="localconfig"><legend>本地配置</legend><table cellpadding="0" cellspacing="3" border="0"><tr><td class="tt">播放性能</td><td><select id="netsPreach" name="netsPreach" class="sel"><option value="0">最短延时</option><option value="1">实时性好</option><option value="2">均衡</option><option value="3">流畅性好</option></select></td><td class="tt">图像尺寸</td><td><select id="wndSize" name="wndSize" class="sel"><option value="0">充满</option><option value="1">4:3</option><option value="2">16:9</option></select></td></tr><tr><td class="tt">规则信息</td><td><select id="rulesInfo" name="rulesInfo" class="sel"><option value="1">启用</option><option value="0">禁用</option></select></td><td class="tt">抓图文件格式</td><td><select id="captureFileFormat" name="captureFileFormat" class="sel"><option value="0">JPEG</option><option value="1">BMP</option></select></td></tr><tr><td class="tt">录像文件打包大小</td><td><select id="packSize" name="packSize" class="sel"><option value="0">256M</option><option value="1">512M</option><option value="2">1G</option></select></td><td class="tt">协议类型</td><td><select id="protocolType" name="protocolType" class="sel"><option value="0">TCP</option><option value="2">UDP</option></select></td></tr><tr><td class="tt">录像文件保存路径</td><td colspan="3"><input id="recordPath" type="text" class="txt" />&nbsp;<input type="button" class="btn" value="浏览" onclick="clickOpenFileDlg('recordPath', 0);" /></td></tr><tr><td class="tt">回放下载保存路径</td><td colspan="3"><input id="downloadPath" type="text" class="txt" />&nbsp;<input type="button" class="btn" value="浏览" onclick="clickOpenFileDlg('downloadPath', 0);" /></td></tr><tr><td class="tt">预览抓图保存路径</td><td colspan="3"><input id="previewPicPath" type="text" class="txt" />&nbsp;<input type="button" class="btn" value="浏览" onclick="clickOpenFileDlg('previewPicPath', 0);" /></td></tr><tr><td class="tt">回放抓图保存路径</td><td colspan="3"><input id="playbackPicPath" type="text" class="txt" />&nbsp;<input type="button" class="btn" value="浏览" onclick="clickOpenFileDlg('playbackPicPath', 0);" /></td></tr><tr><td class="tt">回放剪辑保存路径</td><td colspan="3"><input id="playbackFilePath" type="text" class="txt" />&nbsp;<input type="button" class="btn" value="浏览" onclick="clickOpenFileDlg('playbackFilePath', 0);" /></td></tr><tr><td colspan="4"><input type="button" class="btn" value="获取" onclick="clickGetLocalCfg();" />&nbsp;<input type="button" class="btn" value="设置" onclick="clickSetLocalCfg();" /></td></tr></table></fieldset>
</div>
<div class="left"><fieldset class="preview"><legend>预览</legend><table cellpadding="0" cellspacing="3" border="0"><tr><td class="tt">码流类型</td><td><select id="streamtype" class="sel"><option value="1">主码流</option><option value="2">子码流</option><option value="3">第三码流</option><option value="4">转码码流</option></select></td><td><input type="button" class="btn" value="开始预览" onclick="clickStartRealPlay();" /><input type="button" class="btn" value="停止预览" onclick="clickStopRealPlay();" /></td></tr><tr><td class="tt">音量</td><td><input type="text" id="volume" class="txt" value="50" maxlength="3" />&nbsp;<input type="button" class="btn" value="设置" onclick="clickSetVolume();" />(范围:0~100</td><td><input type="button" class="btn" value="打开声音" onclick="clickOpenSound();" /><input type="button" class="btn" value="关闭声音" onclick="clickCloseSound();" /></td></tr><tr><td class="tt">对讲通道</td><td><select id="audiochannels" class="sel"></select><input type="button" class="btn" value="获取通道" onclick="clickGetAudioInfo();" /></td><td><input type="button" class="btn" value="开始对讲" onclick="clickStartVoiceTalk();" /><input type="button" class="btn" value="停止对讲" onclick="clickStopVoiceTalk();" /></td></tr><tr><td colspan="3"><input type="button" class="btn" value="抓图" onclick="clickCapturePic();" /><input type="button" class="btn" value="开始录像" onclick="clickStartRecord();" /><input type="button" class="btn" value="停止录像" onclick="clickStopRecord();" /></td></tr><tr><td colspan="3"><input type="button" class="btn2" value="启用电子放大" onclick="clickEnableEZoom();" /><input type="button" class="btn2" value="禁用电子放大" onclick="clickDisableEZoom();" /><input type="button" class="btn2" value="启用3D放大" onclick="clickEnable3DZoom();" /><input type="button" class="btn2" value="禁用3D放大" onclick="clickDisable3DZoom();" /><input type="button" class="btn" value="全屏" onclick="clickFullScreen();" /></td></tr></table></fieldset><fieldset class="ptz"><legend>云台控制</legend><table cellpadding="0" cellspacing="3" border="0" class="left"><tr><td><input type="button" class="btn" value="左上" onmousedown="mouseDownPTZControl(5);" onmouseup="mouseUpPTZControl();" /><input type="button" class="btn" value="上" onmousedown="mouseDownPTZControl(1);" onmouseup="mouseUpPTZControl();" /><input type="button" class="btn" value="右上" onmousedown="mouseDownPTZControl(7);" onmouseup="mouseUpPTZControl();" /></td></tr><tr><td><input type="button" class="btn" value="左" onmousedown="mouseDownPTZControl(3);" onmouseup="mouseUpPTZControl();" /><input type="button" class="btn" value="自动" onclick="mouseDownPTZControl(9);" /><input type="button" class="btn" value="右" onmousedown="mouseDownPTZControl(4);" onmouseup="mouseUpPTZControl();" /></td></tr><tr><td><input type="button" class="btn" value="左下" onmousedown="mouseDownPTZControl(6);" onmouseup="mouseUpPTZControl();" /><input type="button" class="btn" value="下" onmousedown="mouseDownPTZControl(2);" onmouseup="mouseUpPTZControl();" /><input type="button" class="btn" value="右下" onmousedown="mouseDownPTZControl(8);" onmouseup="mouseUpPTZControl();" /></td></tr></table><table cellpadding="0" cellspacing="3" border="0" class="left"><tr><td class="tt">云台速度</td><td><select id="ptzspeed" class="sel"><option>1</option><option>2</option><option>3</option><option selected>4</option><option>5</option><option>6</option><option>7</option></select></td></tr><tr><td class="tt">预置点号</td><td><input id="preset" type="text" class="txt" value="1" /></td></tr><tr><td colspan="2"><input type="button" class="btn" value="设置" onclick="clickSetPreset();" /><input type="button" class="btn" value="调用" onclick="clickGoPreset();" /></td></tr></table><table cellpadding="0" cellspacing="3" border="0" class="left"><tr><td class="tt"><input type="button" class="btn2" value="变倍+" onmousedown="PTZZoomIn()" onmouseup="PTZZoomStop()"></td><td><input type="button" class="btn2" value="变倍-" onmousedown="PTZZoomout()" onmouseup="PTZZoomStop()"></td></tr><tr><td class="tt"><input type="button" class="btn2" value="变焦+" onmousedown="PTZFocusIn()" onmouseup="PTZFoucusStop()"></td><td><input type="button" class="btn2" value="变焦-" onmousedown="PTZFoucusOut()" onmouseup="PTZFoucusStop()"></td></tr><tr><td class="tt"><input type="button" class="btn2" value="光圈+" onmousedown="PTZIrisIn()" onmouseup="PTZIrisStop()"></td><td><input type="button" class="btn2" value="光圈-" onmousedown="PTZIrisOut()" onmouseup="PTZIrisStop()"></td></tr></table></fieldset><fieldset class="playback"><legend>回放</legend><table width="100%" cellpadding="0" cellspacing="3" border="0"><tr><td class="tt">开始时间</td><td><input id="starttime" type="text" class="txt" value="2013-12-10 00:00:00" />(时间格式:2013-11-11 12:34:56</td></tr><tr><td class="tt">结束时间</td><td><input id="endtime" type="text" class="txt" value="2013-12-11 23:59:59" /><input type="button" class="btn" value="搜索" onclick="clickRecordSearch(0);" /></td></tr><tr><td colspan="2"><div class="searchdiv"><table id="searchlist" class="searchlist" cellpadding="0" cellspacing="0" border="0"></table></div></td></tr><tr><td colspan="2"><input type="button" class="btn2" value="开始回放" onclick="clickStartPlayback();" /><input type="button" class="btn2" value="停止回放" onclick="clickStopPlayback();" /><input type="button" class="btn" value="倒放" onclick="clickReversePlayback();" /><input type="button" class="btn" value="单帧" onclick="clickFrame();" /><input id="transstream" type="checkbox" class="vtop" />&nbsp;启用转码码流</td></tr><tr><td colspan="2"><input type="button" class="btn" value="暂停" onclick="clickPause();" /><input type="button" class="btn" value="恢复" onclick="clickResume();" /><input type="button" class="btn" value="慢放" onclick="clickPlaySlow();" /><input type="button" class="btn" value="快放" onclick="clickPlayFast();" /></td></tr><tr><td colspan="2"><input type="button" class="btn" value="抓图" onclick="clickCapturePic();" /><input type="button" class="btn2" value="开始剪辑" onclick="clickStartRecord();" /><input type="button" class="btn2" value="停止剪辑" onclick="clickStopRecord();" /><input type="button" class="btn2" value="OSD时间" onclick="clickGetOSDTime();" />&nbsp;<input id="osdtime" type="text" class="txt" readonly /></td></tr></table></fieldset><fieldset class="maintain"><legend>系统维护</legend><table width="100%" cellpadding="0" cellspacing="3" border="0"><tr><td><input type="button" class="btn2" value="导出配置文件" onclick="clickExportDeviceConfig();" /><input type="button" class="btn2" value="检查插件版本" onclick="clickCheckPluginVersion();" /><input type="button" class="btn2" value="远程配置库" onclick="clickRemoteConfig();" /><input type="button" class="btn2" value="恢复默认参数" onclick="clickRestoreDefault();" /></td></tr><tr><td><input id="configFile" type="text" class="txt" />&nbsp;<input type="button" class="btn" value="浏览" onclick="clickOpenFileDlg('configFile', 1);" />&nbsp;<input type="button" class="btn2" value="导入配置文件" onclick="clickImportDeviceConfig();" /></td></tr><tr><td><input id="upgradeFile" type="text" class="txt" />&nbsp;<input type="button" class="btn" value="浏览" onclick="clickOpenFileDlg('upgradeFile', 1);" />&nbsp;<input type="button" class="btn2" value="升级" onclick="clickStartUpgrade();" /></td></tr></table></fieldset><fieldset class="operate"><legend>操作信息</legend><div id="opinfo" class="opinfo"></div></fieldset><fieldset class="callback"><legend>事件回调信息</legend><div id="cbinfo" class="cbinfo"></div></fieldset>
</div>
</body>
<script src="../jquery-1.7.1.min.js"></script>
<script src="../webVideoCtrl.js"></script>
<script src="jk1.js"></script>
</html>

js:

// 初始化插件// 全局保存当前选中窗口
var g_iWndIndex = 0; //可以不用设置这个变量,有窗口参数的接口中,不用传值,开发包会默认使用当前选择窗口
$(function () {// 检查插件是否已经安装过if (-1 == WebVideoCtrl.I_CheckPluginInstall()) {alert("您还未安装过插件,双击开发包目录里的WebComponents.exe安装!");return;}// 初始化插件参数及插入插件WebVideoCtrl.I_InitPlugin(500, 300, {iWndowType: 2,cbSelWnd: function (xmlDoc) {g_iWndIndex = $(xmlDoc).find("SelectWnd").eq(0).text();var szInfo = "当前选择的窗口编号:" + g_iWndIndex;showCBInfo(szInfo);}});WebVideoCtrl.I_InsertOBJECTPlugin("divPlugin");// 检查插件是否最新if (-1 == WebVideoCtrl.I_CheckPluginVersion()) {alert("检测到新的插件版本,双击开发包目录里的WebComponents.exe升级!");return;}// 窗口事件绑定$(window).bind({resize: function () {var $Restart = $("#restartDiv");if ($Restart.length > 0) {var oSize = getWindowSize();$Restart.css({width: oSize.width + "px",height: oSize.height + "px"});}}});//初始化日期时间var szCurTime = dateFormat(new Date(), "yyyy-MM-dd");$("#starttime").val(szCurTime + " 00:00:00");$("#endtime").val(szCurTime + " 23:59:59");
});// 显示操作信息
function showOPInfo(szInfo) {szInfo = "<div>" + dateFormat(new Date(), "yyyy-MM-dd hh:mm:ss") + " " + szInfo + "</div>";$("#opinfo").html(szInfo + $("#opinfo").html());
}// 显示回调信息
function showCBInfo(szInfo) {szInfo = "<div>" + dateFormat(new Date(), "yyyy-MM-dd hh:mm:ss") + " " + szInfo + "</div>";$("#cbinfo").html(szInfo + $("#cbinfo").html());
}// 格式化时间
function dateFormat(oDate, fmt) {var o = {"M+": oDate.getMonth() + 1, //月份"d+": oDate.getDate(), //日"h+": oDate.getHours(), //小时"m+": oDate.getMinutes(), //分"s+": oDate.getSeconds(), //秒"q+": Math.floor((oDate.getMonth() + 3) / 3), //季度"S": oDate.getMilliseconds()//毫秒};if (/(y+)/.test(fmt)) {fmt = fmt.replace(RegExp.$1, (oDate.getFullYear() + "").substr(4 - RegExp.$1.length));}for (var k in o) {if (new RegExp("(" + k + ")").test(fmt)) {fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));}}return fmt;
}// 获取窗口尺寸
function getWindowSize() {var nWidth = $(this).width() + $(this).scrollLeft(),nHeight = $(this).height() + $(this).scrollTop();return {width: nWidth, height: nHeight};
}// 打开选择框 0:文件夹  1:文件
function clickOpenFileDlg(id, iType) {var szDirPath = WebVideoCtrl.I_OpenFileDlg(iType);if (szDirPath != -1 && szDirPath != "" && szDirPath != null) {$("#" + id).val(szDirPath);}
}// 获取本地参数
function clickGetLocalCfg() {var xmlDoc = WebVideoCtrl.I_GetLocalCfg();$("#netsPreach").val($(xmlDoc).find("BuffNumberType").eq(0).text());$("#wndSize").val($(xmlDoc).find("PlayWndType").eq(0).text());$("#rulesInfo").val($(xmlDoc).find("IVSMode").eq(0).text());$("#captureFileFormat").val($(xmlDoc).find("CaptureFileFormat").eq(0).text());$("#packSize").val($(xmlDoc).find("PackgeSize").eq(0).text());$("#recordPath").val($(xmlDoc).find("RecordPath").eq(0).text());$("#downloadPath").val($(xmlDoc).find("DownloadPath").eq(0).text());$("#previewPicPath").val($(xmlDoc).find("CapturePath").eq(0).text());$("#playbackPicPath").val($(xmlDoc).find("PlaybackPicPath").eq(0).text());$("#playbackFilePath").val($(xmlDoc).find("PlaybackFilePath").eq(0).text());$("#protocolType").val($(xmlDoc).find("ProtocolType").eq(0).text());showOPInfo("本地配置获取成功!");
}// 设置本地参数
function clickSetLocalCfg() {var arrXml = [],szInfo = "";arrXml.push("<LocalConfigInfo>");arrXml.push("<PackgeSize>" + $("#packSize").val() + "</PackgeSize>");arrXml.push("<PlayWndType>" + $("#wndSize").val() + "</PlayWndType>");arrXml.push("<BuffNumberType>" + $("#netsPreach").val() + "</BuffNumberType>");arrXml.push("<RecordPath>" + $("#recordPath").val() + "</RecordPath>");arrXml.push("<CapturePath>" + $("#previewPicPath").val() + "</CapturePath>");arrXml.push("<PlaybackFilePath>" + $("#playbackFilePath").val() + "</PlaybackFilePath>");arrXml.push("<PlaybackPicPath>" + $("#playbackPicPath").val() + "</PlaybackPicPath>");arrXml.push("<DownloadPath>" + $("#downloadPath").val() + "</DownloadPath>");arrXml.push("<IVSMode>" + $("#rulesInfo").val() + "</IVSMode>");arrXml.push("<CaptureFileFormat>" + $("#captureFileFormat").val() + "</CaptureFileFormat>");arrXml.push("<ProtocolType>" + $("#protocolType").val() + "</ProtocolType>");arrXml.push("</LocalConfigInfo>");var iRet = WebVideoCtrl.I_SetLocalCfg(arrXml.join(""));if (0 == iRet) {szInfo = "本地配置设置成功!";} else {szInfo = "本地配置设置失败!";}showOPInfo(szInfo);
}// 窗口分割数
function changeWndNum(iType) {iType = parseInt(1, 10);//修改WebVideoCtrl.I_ChangeWndNum(iType);
}// 登录
function clickLogin() {/*var szIP = $("#loginip").val(),szPort = $("#port").val(),szUsername = $("#username").val(),szPassword = $("#password").val();
*/var szIP = "172.17.136.8",//修改szPort = '80',//修改szUsername = 'admin',//修改szPassword = 'jj123456';//修改if ("" == szIP || "" == szPort) {return;}
//修改var iRet = WebVideoCtrl.I_Login(szIP, 1, szPort, szUsername, szPassword, {success: function (xmlDoc) {// console.log('登录成功 1122');showOPInfo(szIP + " 登录成功!");$("#ip").prepend("<option value='" + szIP + "'>" + szIP + "</option>");setTimeout(function () {$("#ip").val(szIP);getChannelInfo();}, 10);},error: function () {// console.log('登录失败 1122');showOPInfo(szIP + " 登录失败!");}});if (-1 == iRet) {showOPInfo(szIP + " 已登录过!");}setTimeout(function () {clickStartRealPlay();}, 5000);}// 退出
function clickLogout() {var szIP = $("#ip").val(),szInfo = "";if (szIP == "") {return;}var iRet = WebVideoCtrl.I_Logout(szIP);if (0 == iRet) {szInfo = "退出成功!";$("#ip option[value='" + szIP + "']").remove();getChannelInfo();} else {szInfo = "退出失败!";}showOPInfo(szIP + " " + szInfo);
}// 获取设备信息
function clickGetDeviceInfo() {var szIP = $("#ip").val();if ("" == szIP) {return;}WebVideoCtrl.I_GetDeviceInfo(szIP, {success: function (xmlDoc) {var arrStr = [];arrStr.push("设备名称:" + $(xmlDoc).find("deviceName").eq(0).text() + "\r\n");arrStr.push("设备ID:" + $(xmlDoc).find("deviceID").eq(0).text() + "\r\n");arrStr.push("型号:" + $(xmlDoc).find("model").eq(0).text() + "\r\n");arrStr.push("设备序列号:" + $(xmlDoc).find("serialNumber").eq(0).text() + "\r\n");arrStr.push("MAC地址:" + $(xmlDoc).find("macAddress").eq(0).text() + "\r\n");arrStr.push("主控版本:" + $(xmlDoc).find("firmwareVersion").eq(0).text() + " " + $(xmlDoc).find("firmwareReleasedDate").eq(0).text() + "\r\n");arrStr.push("编码版本:" + $(xmlDoc).find("encoderVersion").eq(0).text() + " " + $(xmlDoc).find("encoderReleasedDate").eq(0).text() + "\r\n");showOPInfo(szIP + " 获取设备信息成功!");alert(arrStr.join(""));},error: function () {showOPInfo(szIP + " 获取设备信息失败!");}});
}// 获取通道
function getChannelInfo() {var szIP = $("#ip").val(),oSel = $("#channels").empty(),nAnalogChannel = 0;if ("" == szIP) {return;}// 模拟通道WebVideoCtrl.I_GetAnalogChannelInfo(szIP, {async: false,success: function (xmlDoc) {var oChannels = $(xmlDoc).find("VideoInputChannel");nAnalogChannel = oChannels.length;$.each(oChannels, function (i) {var id = parseInt($(this).find("id").eq(0).text(), 10),name = $(this).find("name").eq(0).text();if ("" == name) {name = "Camera " + (id < 9 ? "0" + id : id);}oSel.append("<option value='" + id + "' bZero='false'>" + name + "</option>");});showOPInfo(szIP + " 获取模拟通道成功!");},error: function () {showOPInfo(szIP + " 获取模拟通道失败!");}});console.log(szIP,oSel,nAnalogChannel);// 数字通道WebVideoCtrl.I_GetDigitalChannelInfo(szIP, {async: false,success: function (xmlDoc) {var oChannels = $(xmlDoc).find("InputProxyChannelStatus");$.each(oChannels, function (i) {var id = parseInt($(this).find("id").eq(0).text(), 10),name = $(this).find("name").eq(0).text(),online = $(this).find("online").eq(0).text();if ("false" == online) {// 过滤禁用的数字通道return true;}if ("" == name) {name = "IPCamera " + ((id - nAnalogChannel) < 9 ? "0" + (id - nAnalogChannel) : (id - nAnalogChannel));}oSel.append("<option value='" + id + "' bZero='false'>" + name + "</option>");});showOPInfo(szIP + " 获取数字通道成功!");},error: function () {showOPInfo(szIP + " 获取数字通道失败!");}});// 零通道WebVideoCtrl.I_GetZeroChannelInfo(szIP, {async: false,success: function (xmlDoc) {var oChannels = $(xmlDoc).find("ZeroVideoChannel");$.each(oChannels, function (i) {var id = parseInt($(this).find("id").eq(0).text(), 10),name = $(this).find("name").eq(0).text();if ("" == name) {name = "Zero Channel " + (id < 9 ? "0" + id : id);}if ("true" == $(this).find("enabled").eq(0).text()) {// 过滤禁用的零通道oSel.append("<option value='" + id + "' bZero='true'>" + name + "</option>");}});showOPInfo(szIP + " 获取零通道成功!");},error: function () {showOPInfo(szIP + " 获取零通道失败!");}});
}// 获取数字通道
function clickGetDigitalChannelInfo() {var szIP = $("#ip").val(),iAnalogChannelNum = 0;$("#digitalchannellist").empty();if ("" == szIP) {return;}// 模拟通道WebVideoCtrl.I_GetAnalogChannelInfo(szIP, {async: false,success: function (xmlDoc) {iAnalogChannelNum = $(xmlDoc).find("VideoInputChannel").length;},error: function () {}});// 数字通道WebVideoCtrl.I_GetDigitalChannelInfo(szIP, {async: false,success: function (xmlDoc) {var oChannels = $(xmlDoc).find("InputProxyChannelStatus");$.each(oChannels, function () {var id = parseInt($(this).find("id").eq(0).text(), 10),ipAddress = $(this).find("ipAddress").eq(0).text(),srcInputPort = $(this).find("srcInputPort").eq(0).text(),managePortNo = $(this).find("managePortNo").eq(0).text(),online = $(this).find("online").eq(0).text(),proxyProtocol = $(this).find("proxyProtocol").eq(0).text();var objTr = $("#digitalchannellist").get(0).insertRow(-1);var objTd = objTr.insertCell(0);objTd.innerHTML = (id - iAnalogChannelNum) < 10 ? "D0" + (id - iAnalogChannelNum) : "D" + (id - iAnalogChannelNum);objTd = objTr.insertCell(1);objTd.width = "25%";objTd.innerHTML = ipAddress;objTd = objTr.insertCell(2);objTd.width = "15%";objTd.innerHTML = srcInputPort;objTd = objTr.insertCell(3);objTd.width = "20%";objTd.innerHTML = managePortNo;objTd = objTr.insertCell(4);objTd.width = "15%";objTd.innerHTML = "true" == online ? "在线" : "离线";objTd = objTr.insertCell(5);objTd.width = "25%";objTd.innerHTML = proxyProtocol;});showOPInfo(szIP + " 获取数字通道成功!");},error: function () {showOPInfo(szIP + " 没有数字通道!");}});
}// 开始预览
function clickStartRealPlay() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),szIP = '172.17.136.8',streamtype//修改ipiStreamType = parseInt(3, 10),//通道//修改  1主  2子  3第三 4其他iChannelID = 1,bZeroChannel = $("#channels option").eq($("#channels").get(0).selectedIndex).attr("bZero") == "true" ? true : false,szInfo = "";if ("" == szIP) {return;}// console.log('开始预览 --**',oWndInfo,szIP,iStreamType,iChannelID,bZeroChannel);if (oWndInfo != null) {// 已经在播放了,先停止WebVideoCtrl.I_Stop();}var iRet = WebVideoCtrl.I_StartRealPlay(szIP, {iStreamType: iStreamType,iChannelID: iChannelID,bZeroChannel: bZeroChannel});console.log(szIP, {iStreamType: iStreamType,iChannelID: iChannelID,bZeroChannel: bZeroChannel},'citrix',iRet);if (0 == iRet) {szInfo = "开始预览成功!";} else {szInfo = "开始预览失败!";}showOPInfo(szIP + " " + szInfo);
}// 停止预览
function clickStopRealPlay() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),szInfo = "";if (oWndInfo != null) {var iRet = WebVideoCtrl.I_Stop();if (0 == iRet) {szInfo = "停止预览成功!";} else {szInfo = "停止预览失败!";}showOPInfo(oWndInfo.szIP + " " + szInfo);}
}// 打开声音
function clickOpenSound() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),szInfo = "";if (oWndInfo != null) {var allWndInfo = WebVideoCtrl.I_GetWindowStatus();// 循环遍历所有窗口,如果有窗口打开了声音,先关闭for (var i = 0, iLen = allWndInfo.length; i < iLen; i++) {oWndInfo = allWndInfo[i];if (oWndInfo.bSound) {WebVideoCtrl.I_CloseSound(oWndInfo.iIndex);break;}}var iRet = WebVideoCtrl.I_OpenSound();if (0 == iRet) {szInfo = "打开声音成功!";} else {szInfo = "打开声音失败!";}showOPInfo(oWndInfo.szIP + " " + szInfo);}
}// 关闭声音
function clickCloseSound() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),szInfo = "";if (oWndInfo != null) {var iRet = WebVideoCtrl.I_CloseSound();if (0 == iRet) {szInfo = "关闭声音成功!";} else {szInfo = "关闭声音失败!";}showOPInfo(oWndInfo.szIP + " " + szInfo);}
}// 设置音量
function clickSetVolume() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),iVolume = parseInt($("#volume").val(), 10),szInfo = "";if (oWndInfo != null) {var iRet = WebVideoCtrl.I_SetVolume(iVolume);if (0 == iRet) {szInfo = "音量设置成功!";} else {szInfo = "音量设置失败!";}showOPInfo(oWndInfo.szIP + " " + szInfo);}
}// 抓图
function clickCapturePic() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),szInfo = "";if (oWndInfo != null) {var szChannelID = $("#channels").val(),szPicName = oWndInfo.szIP + "_" + szChannelID + "_" + new Date().getTime(),iRet = WebVideoCtrl.I_CapturePic(szPicName);if (0 == iRet) {szInfo = "抓图成功!";} else {szInfo = "抓图失败!";}showOPInfo(oWndInfo.szIP + " " + szInfo);}
}// 开始录像
function clickStartRecord() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),szInfo = "";if (oWndInfo != null) {var szChannelID = $("#channels").val(),szFileName = oWndInfo.szIP + "_" + szChannelID + "_" + new Date().getTime(),iRet = WebVideoCtrl.I_StartRecord(szFileName);if (0 == iRet) {szInfo = "开始录像成功!";} else {szInfo = "开始录像失败!";}showOPInfo(oWndInfo.szIP + " " + szInfo);}
}// 停止录像
function clickStopRecord() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),szInfo = "";if (oWndInfo != null) {var iRet = WebVideoCtrl.I_StopRecord();if (0 == iRet) {szInfo = "停止录像成功!";} else {szInfo = "停止录像失败!";}showOPInfo(oWndInfo.szIP + " " + szInfo);}
}// 获取对讲通道
function clickGetAudioInfo() {var szIP = $("#ip").val();if ("" == szIP) {return;}WebVideoCtrl.I_GetAudioInfo(szIP, {success: function (xmlDoc) {var oAudioChannels = $(xmlDoc).find("TwoWayAudioChannel"),oSel = $("#audiochannels").empty();$.each(oAudioChannels, function () {var id = $(this).find("id").eq(0).text();oSel.append("<option value='" + id + "'>" + id + "</option>");});showOPInfo(szIP + " 获取对讲通道成功!");},error: function () {showOPInfo(szIP + " 获取对讲通道失败!");}});
}// 开始对讲
function clickStartVoiceTalk() {var szIP = $("#ip").val(),iAudioChannel = parseInt($("#audiochannels").val(), 10),szInfo = "";if ("" == szIP) {return;}if (isNaN(iAudioChannel)){alert("请选择对讲通道!");return;}var iRet = WebVideoCtrl.I_StartVoiceTalk(szIP, iAudioChannel);if (0 == iRet) {szInfo = "开始对讲成功!";} else {szInfo = "开始对讲失败!";}showOPInfo(szIP + " " + szInfo);
}// 停止对讲
function clickStopVoiceTalk() {var szIP = $("#ip").val(),iRet = WebVideoCtrl.I_StopVoiceTalk(),szInfo = "";if ("" == szIP) {return;}if (0 == iRet) {szInfo = "停止对讲成功!";} else {szInfo = "停止对讲失败!";}showOPInfo(szIP + " " + szInfo);
}// 启用电子放大
function clickEnableEZoom() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),szInfo = "";if (oWndInfo != null) {var iRet = WebVideoCtrl.I_EnableEZoom();if (0 == iRet) {szInfo = "启用电子放大成功!";} else {szInfo = "启用电子放大失败!";}showOPInfo(oWndInfo.szIP + " " + szInfo);}
}// 禁用电子放大
function clickDisableEZoom() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),szInfo = "";if (oWndInfo != null) {var iRet = WebVideoCtrl.I_DisableEZoom();if (0 == iRet) {szInfo = "禁用电子放大成功!";} else {szInfo = "禁用电子放大失败!";}showOPInfo(oWndInfo.szIP + " " + szInfo);}
}// 启用3D放大
function clickEnable3DZoom() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),szInfo = "";if (oWndInfo != null) {var iRet = WebVideoCtrl.I_Enable3DZoom();if (0 == iRet) {szInfo = "启用3D放大成功!";} else {szInfo = "启用3D放大失败!";}showOPInfo(oWndInfo.szIP + " " + szInfo);}
}// 禁用3D放大
function clickDisable3DZoom() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),szInfo = "";if (oWndInfo != null) {var iRet = WebVideoCtrl.I_Disable3DZoom();if (0 == iRet) {szInfo = "禁用3D放大成功!";} else {szInfo = "禁用3D放大失败!";}showOPInfo(oWndInfo.szIP + " " + szInfo);}
}// 全屏
function clickFullScreen() {WebVideoCtrl.I_FullScreen(true);
}// PTZ控制 9为自动,1,2,3,4,5,6,7,8为方向PTZ
var g_bPTZAuto = false;
function mouseDownPTZControl(iPTZIndex) {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),bZeroChannel = $("#channels option").eq($("#channels").get(0).selectedIndex).attr("bZero") == "true" ? true : false,iPTZSpeed = $("#ptzspeed").val(),bStop = false;if (bZeroChannel) {// 零通道不支持云台return;}if (oWndInfo != null) {if (9 == iPTZIndex && g_bPTZAuto) {iPTZSpeed = 0;// 自动开启后,速度置为0可以关闭自动bStop = true;} else {g_bPTZAuto = false;// 点击其他方向,自动肯定会被关闭bStop = false;}WebVideoCtrl.I_PTZControl(iPTZIndex, bStop, {iPTZSpeed: iPTZSpeed,success: function (xmlDoc) {if (9 == iPTZIndex) {g_bPTZAuto = !g_bPTZAuto;}showOPInfo(oWndInfo.szIP + " 开启云台成功!");},error: function () {showOPInfo(oWndInfo.szIP + " 开启云台失败!");}});}
}// 方向PTZ停止
function mouseUpPTZControl() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);if (oWndInfo != null) {WebVideoCtrl.I_PTZControl(1, true, {success: function (xmlDoc) {showOPInfo(oWndInfo.szIP + " 停止云台成功!");},error: function () {showOPInfo(oWndInfo.szIP + " 停止云台失败!");}});}
}// 设置预置点
function clickSetPreset() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),iPresetID = parseInt($("#preset").val(), 10);if (oWndInfo != null) {WebVideoCtrl.I_SetPreset(iPresetID, {success: function (xmlDoc) {showOPInfo(oWndInfo.szIP + " 设置预置点成功!");},error: function () {showOPInfo(oWndInfo.szIP + " 设置预置点失败!");}});}
}// 调用预置点
function clickGoPreset() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),iPresetID = parseInt($("#preset").val(), 10);if (oWndInfo != null) {WebVideoCtrl.I_GoPreset(iPresetID, {success: function (xmlDoc) {showOPInfo(oWndInfo.szIP + " 调用预置点成功!");},error: function () {showOPInfo(oWndInfo.szIP + " 调用预置点失败!");}});}
}// 搜索录像
var iSearchTimes = 0;
function clickRecordSearch(iType) {var szIP = $("#ip").val(),iChannelID = $("#channels").val(),bZeroChannel = $("#channels option").eq($("#channels").get(0).selectedIndex).attr("bZero") == "true" ? true : false,szStartTime = $("#starttime").val(),szEndTime = $("#endtime").val();if ("" == szIP) {return;}if (bZeroChannel) {// 零通道不支持录像搜索return;}if (0 == iType) {// 首次搜索$("#searchlist").empty();iSearchTimes = 0;}WebVideoCtrl.I_RecordSearch(szIP, iChannelID, szStartTime, szEndTime, {iSearchPos: iSearchTimes * 40,success: function (xmlDoc) {if("MORE" === $(xmlDoc).find("responseStatusStrg").eq(0).text()) {for(var i = 0, nLen = $(xmlDoc).find("searchMatchItem").length; i < nLen; i++) {var szPlaybackURI = $(xmlDoc).find("playbackURI").eq(i).text();if(szPlaybackURI.indexOf("name=") < 0) {break;}var szStartTime = $(xmlDoc).find("startTime").eq(i).text();var szEndTime = $(xmlDoc).find("endTime").eq(i).text();var szFileName = szPlaybackURI.substring(szPlaybackURI.indexOf("name=") + 5, szPlaybackURI.indexOf("&size="));var objTr = $("#searchlist").get(0).insertRow(-1);var objTd = objTr.insertCell(0);objTd.id = "downloadTd" + i;objTd.innerHTML = iSearchTimes * 40 + (i + 1);objTd = objTr.insertCell(1);objTd.width = "30%";objTd.innerHTML = szFileName;objTd = objTr.insertCell(2);objTd.width = "30%";objTd.innerHTML = (szStartTime.replace("T", " ")).replace("Z", "");objTd = objTr.insertCell(3);objTd.width = "30%";objTd.innerHTML = (szEndTime.replace("T", " ")).replace("Z", "");objTd = objTr.insertCell(4);objTd.width = "10%";objTd.innerHTML = "<a href='javascript:;' οnclick='clickStartDownloadRecord(" + i + ");'>下载</a>";$("#downloadTd" + i).data("playbackURI", szPlaybackURI);}iSearchTimes++;clickRecordSearch(1);// 继续搜索} else if ("OK" === $(xmlDoc).find("responseStatusStrg").eq(0).text()) {var iLength = $(xmlDoc).find("searchMatchItem").length;for(var i = 0; i < iLength; i++) {var szPlaybackURI = $(xmlDoc).find("playbackURI").eq(i).text();if(szPlaybackURI.indexOf("name=") < 0) {break;}var szStartTime = $(xmlDoc).find("startTime").eq(i).text();var szEndTime = $(xmlDoc).find("endTime").eq(i).text();var szFileName = szPlaybackURI.substring(szPlaybackURI.indexOf("name=") + 5, szPlaybackURI.indexOf("&size="));var objTr = $("#searchlist").get(0).insertRow(-1);var objTd = objTr.insertCell(0);objTd.id = "downloadTd" + i;objTd.innerHTML = iSearchTimes * 40 + (i + 1);objTd = objTr.insertCell(1);objTd.width = "30%";objTd.innerHTML = szFileName;objTd = objTr.insertCell(2);objTd.width = "30%";objTd.innerHTML = (szStartTime.replace("T", " ")).replace("Z", "");objTd = objTr.insertCell(3);objTd.width = "30%";objTd.innerHTML = (szEndTime.replace("T", " ")).replace("Z", "");objTd = objTr.insertCell(4);objTd.width = "10%";objTd.innerHTML = "<a href='javascript:;' οnclick='clickStartDownloadRecord(" + i + ");'>下载</a>";$("#downloadTd" + i).data("playbackURI", szPlaybackURI);}showOPInfo(szIP + " 搜索录像文件成功!");} else if("NO MATCHES" === $(xmlDoc).find("responseStatusStrg").eq(0).text()) {setTimeout(function() {showOPInfo(szIP + " 没有录像文件!");}, 50);}},error: function () {showOPInfo(szIP + " 搜索录像文件失败!");}});
}// 开始回放
function clickStartPlayback() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),szIP = $("#ip").val(),bZeroChannel = $("#channels option").eq($("#channels").get(0).selectedIndex).attr("bZero") == "true" ? true : false,iChannelID = $("#channels").val(),szStartTime = $("#starttime").val(),szEndTime = $("#endtime").val(),szInfo = "",bChecked = $("#transstream").prop("checked"),iRet = -1;if ("" == szIP) {return;}if (bZeroChannel) {// 零通道不支持回放return;}if (oWndInfo != null) {// 已经在播放了,先停止WebVideoCtrl.I_Stop();}if (bChecked) {// 启用转码回放var oTransCodeParam = {TransFrameRate: "16",// 0:全帧率,5:1,6:2,7:4,8:6,9:8,10:10,11:12,12:16,14:15,15:18,13:20,16:22TransResolution: "2",// 255:Auto,3:4CIF,2:QCIF,1:CIFTransBitrate: "23"// 2:32K,3:48K,4:64K,5:80K,6:96K,7:128K,8:160K,9:192K,10:224K,11:256K,12:320K,13:384K,14:448K,15:512K,16:640K,17:768K,18:896K,19:1024K,20:1280K,21:1536K,22:1792K,23:2048K,24:3072K,25:4096K,26:8192K};iRet = WebVideoCtrl.I_StartPlayback(szIP, {iChannelID: iChannelID,szStartTime: szStartTime,szEndTime: szEndTime,oTransCodeParam: oTransCodeParam});} else {iRet = WebVideoCtrl.I_StartPlayback(szIP, {iChannelID: iChannelID,szStartTime: szStartTime,szEndTime: szEndTime});}if (0 == iRet) {szInfo = "开始回放成功!";} else {szInfo = "开始回放失败!";}showOPInfo(szIP + " " + szInfo);
}// 停止回放
function clickStopPlayback() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),szInfo = "";if (oWndInfo != null) {var iRet = WebVideoCtrl.I_Stop();if (0 == iRet) {szInfo = "停止回放成功!";} else {szInfo = "停止回放失败!";}showOPInfo(oWndInfo.szIP + " " + szInfo);}
}// 开始倒放
function clickReversePlayback() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),szIP = $("#ip").val(),bZeroChannel = $("#channels option").eq($("#channels").get(0).selectedIndex).attr("bZero") == "true" ? true : false,iChannelID = $("#channels").val(),szStartTime = $("#starttime").val(),szEndTime = $("#endtime").val(),szInfo = "";if ("" == szIP) {return;}if (bZeroChannel) {// 零通道不支持回放return;}if (oWndInfo != null) {// 已经在播放了,先停止WebVideoCtrl.I_Stop();}var iRet = WebVideoCtrl.I_ReversePlayback(szIP, {iChannelID: iChannelID,szStartTime: szStartTime,szEndTime: szEndTime});if (0 == iRet) {szInfo = "开始倒放成功!";} else {szInfo = "开始倒放失败!";}showOPInfo(szIP + " " + szInfo);
}// 单帧
function clickFrame() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),szInfo = "";if (oWndInfo != null) {var iRet = WebVideoCtrl.I_Frame();if (0 == iRet) {szInfo = "单帧播放成功!";} else {szInfo = "单帧播放失败!";}showOPInfo(oWndInfo.szIP + " " + szInfo);}
}// 暂停
function clickPause() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),szInfo = "";if (oWndInfo != null) {var iRet = WebVideoCtrl.I_Pause();if (0 == iRet) {szInfo = "暂停成功!";} else {szInfo = "暂停失败!";}showOPInfo(oWndInfo.szIP + " " + szInfo);}
}// 恢复
function clickResume() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),szInfo = "";if (oWndInfo != null) {var iRet = WebVideoCtrl.I_Resume();if (0 == iRet) {szInfo = "恢复成功!";} else {szInfo = "恢复失败!";}showOPInfo(oWndInfo.szIP + " " + szInfo);}
}// 慢放
function clickPlaySlow() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),szInfo = "";if (oWndInfo != null) {var iRet = WebVideoCtrl.I_PlaySlow();if (0 == iRet) {szInfo = "慢放成功!";} else {szInfo = "慢放失败!";}showOPInfo(oWndInfo.szIP + " " + szInfo);}
}// 快放
function clickPlayFast() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),szInfo = "";if (oWndInfo != null) {var iRet = WebVideoCtrl.I_PlayFast();if (0 == iRet) {szInfo = "快放成功!";} else {szInfo = "快放失败!";}showOPInfo(oWndInfo.szIP + " " + szInfo);}
}// OSD时间
function clickGetOSDTime() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);if (oWndInfo != null) {var szTime = WebVideoCtrl.I_GetOSDTime();if (szTime != -1) {$("#osdtime").val(szTime);showOPInfo(oWndInfo.szIP + " 获取OSD时间成功!");} else {showOPInfo(oWndInfo.szIP + " 获取OSD时间失败!");}}
}// 下载录像
var iDownloadID = -1;
var tDownloadProcess = 0;
function clickStartDownloadRecord(i) {var szIP = $("#ip").val(),szChannelID = $("#channels").val(),szFileName = szIP + "_" + szChannelID + "_" + new Date().getTime(),szPlaybackURI = $("#downloadTd" + i).data("playbackURI");if ("" == szIP) {return;}iDownloadID = WebVideoCtrl.I_StartDownloadRecord(szIP, szPlaybackURI, szFileName);if (iDownloadID < 0) {var iErrorValue = WebVideoCtrl.I_GetLastError();if (34 == iErrorValue) {showOPInfo(szIP + " 已下载!");} else if (33 == iErrorValue) {showOPInfo(szIP + " 空间不足!");} else {showOPInfo(szIP + " 下载失败!");}} else {$("<div id='downProcess' class='freeze'></div>").appendTo("body");tDownloadProcess = setInterval("downProcess(" + i + ")", 1000);}
}
// 下载进度
function downProcess() {var iStatus = WebVideoCtrl.I_GetDownloadStatus(iDownloadID);if (0 == iStatus) {$("#downProcess").css({width: $("#searchlist").width() + "px",height: "100px",lineHeight: "100px",left: $("#searchlist").offset().left + "px",top: $("#searchlist").offset().top + "px"});var iProcess = WebVideoCtrl.I_GetDownloadProgress(iDownloadID);if (iProcess < 0) {clearInterval(tDownloadProcess);tDownloadProcess = 0;m_iDownloadID = -1;} else if (iProcess < 100) {$("#downProcess").text(iProcess + "%");} else {$("#downProcess").text("100%");setTimeout(function () {$("#downProcess").remove();}, 1000);WebVideoCtrl.I_StopDownloadRecord(iDownloadID);showOPInfo("录像下载完成");clearInterval(tDownloadProcess);tDownloadProcess = 0;m_iDownloadID = -1;}} else {WebVideoCtrl.I_StopDownloadRecord(iDownloadID);clearInterval(tDownloadProcess);tDownloadProcess = 0;iDownloadID = -1;}
}// 导出配置文件
function clickExportDeviceConfig() {var szIP = $("#ip").val(),szInfo = "";if ("" == szIP) {return;}var iRet = WebVideoCtrl.I_ExportDeviceConfig(szIP);if (0 == iRet) {szInfo = "导出配置文件成功!";} else {szInfo = "导出配置文件失败!";}showOPInfo(szIP + " " + szInfo);
}// 导入配置文件
function clickImportDeviceConfig() {var szIP = $("#ip").val(),szFileName = $("#configFile").val();if ("" == szIP) {return;}if ("" == szFileName) {alert("请选择配置文件!");return;}var iRet = WebVideoCtrl.I_ImportDeviceConfig(szIP, szFileName);if (0 == iRet) {WebVideoCtrl.I_Restart(szIP, {success: function (xmlDoc) {$("<div id='restartDiv' class='freeze'>重启中...</div>").appendTo("body");var oSize = getWindowSize();$("#restartDiv").css({width: oSize.width + "px",height: oSize.height + "px",lineHeight: oSize.height + "px",left: 0,top: 0});setTimeout("reconnect('" + szIP + "')", 20000);},error: function () {showOPInfo(szIP + " 重启失败!");}});} else {showOPInfo(szIP + " 导入失败!");}
}// 重连
function reconnect(szIP) {WebVideoCtrl.I_Reconnect(szIP, {success: function (xmlDoc) {$("#restartDiv").remove();},error: function () {setTimeout(function () {reconnect(szIP);}, 5000);}});
}// 开始升级
m_tUpgrade = 0;
function clickStartUpgrade(szIP) {var szIP = $("#ip").val(),szFileName = $("#upgradeFile").val();if ("" == szIP) {return;}if ("" == szFileName) {alert("请选择升级文件!");return;}var iRet = WebVideoCtrl.I_StartUpgrade(szIP, szFileName);if (0 == iRet) {m_tUpgrade = setInterval("getUpgradeStatus('" + szIP + "')", 1000);} else {showOPInfo(szIP + " 升级失败!");}
}// 获取升级状态
function getUpgradeStatus(szIP) {var iStatus = WebVideoCtrl.I_UpgradeStatus();if (iStatus == 0) {var iProcess = WebVideoCtrl.I_UpgradeProgress();if (iProcess < 0) {clearInterval(m_tUpgrade);m_tUpgrade = 0;showOPInfo(szIP + " 获取进度失败!");return;} else if (iProcess < 100) {if (0 == $("#restartDiv").length) {$("<div id='restartDiv' class='freeze'></div>").appendTo("body");var oSize = getWindowSize();$("#restartDiv").css({width: oSize.width + "px",height: oSize.height + "px",lineHeight: oSize.height + "px",left: 0,top: 0});}$("#restartDiv").text(iProcess + "%");} else {WebVideoCtrl.I_StopUpgrade();clearInterval(m_tUpgrade);m_tUpgrade = 0;$("#restartDiv").remove();WebVideoCtrl.I_Restart(szIP, {success: function (xmlDoc) {$("<div id='restartDiv' class='freeze'>重启中...</div>").appendTo("body");var oSize = getWindowSize();$("#restartDiv").css({width: oSize.width + "px",height: oSize.height + "px",lineHeight: oSize.height + "px",left: 0,top: 0});setTimeout("reconnect('" + szIP + "')", 20000);},error: function () {showOPInfo(szIP + " 重启失败!");}});}} else if (iStatus == 1) {WebVideoCtrl.I_StopUpgrade();showOPInfo(szIP + " 升级失败!");clearInterval(m_tUpgrade);m_tUpgrade = 0;} else if (iStatus == 2) {mWebVideoCtrl.I_StopUpgrade();showOPInfo(szIP + " 语言不匹配!");clearInterval(m_tUpgrade);m_tUpgrade = 0;} else {mWebVideoCtrl.I_StopUpgrade();showOPInfo(szIP + " 获取状态失败!");clearInterval(m_tUpgrade);m_tUpgrade = 0;}
}// 检查插件版本
function clickCheckPluginVersion() {var iRet = WebVideoCtrl.I_CheckPluginVersion();if (0 == iRet) {alert("您的插件版本已经是最新的!");} else {alert("检测到新的插件版本!");}
}// 远程配置库
function clickRemoteConfig() {var szIP = $("#ip").val(),iDevicePort = parseInt($("#deviceport").val(), 10) || "",szInfo = "";if ("" == szIP) {return;}var iRet = WebVideoCtrl.I_RemoteConfig(szIP, {iDevicePort: iDevicePort,iLan: 1});if (-1 == iRet) {szInfo = "调用远程配置库失败!";} else {szInfo = "调用远程配置库成功!";}showOPInfo(szIP + " " + szInfo);
}function clickRestoreDefault() {var szIP = $("#ip").val(),szMode = "basic";WebVideoCtrl.I_RestoreDefault(szIP, szMode, {success: function (xmlDoc) {$("#restartDiv").remove();showOPInfo(szIP + " 恢复默认参数成功!");//恢复完成后需要重启WebVideoCtrl.I_Restart(szIP, {success: function (xmlDoc) {$("<div id='restartDiv' class='freeze'>重启中...</div>").appendTo("body");var oSize = getWindowSize();$("#restartDiv").css({width: oSize.width + "px",height: oSize.height + "px",lineHeight: oSize.height + "px",left: 0,top: 0});setTimeout("reconnect('" + szIP + "')", 20000);},error: function () {showOPInfo(szIP + " 重启失败!");}});},error: function () {showOPInfo(szIP + " 恢复默认参数失败!");}});
}function PTZZoomIn() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);if (oWndInfo != null) {WebVideoCtrl.I_PTZControl(10, false, {iWndIndex: g_iWndIndex,success: function (xmlDoc) {showOPInfo(oWndInfo.szIP + " 调焦+成功!");},error: function () {showOPInfo(oWndInfo.szIP + "  调焦+失败!");}});}
}function PTZZoomout() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);if (oWndInfo != null) {WebVideoCtrl.I_PTZControl(11, false, {iWndIndex: g_iWndIndex,success: function (xmlDoc) {showOPInfo(oWndInfo.szIP + " 调焦-成功!");},error: function () {showOPInfo(oWndInfo.szIP + "  调焦-失败!");}});}
}function PTZZoomStop() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);if (oWndInfo != null) {WebVideoCtrl.I_PTZControl(11, true, {iWndIndex: g_iWndIndex,success: function (xmlDoc) {showOPInfo(oWndInfo.szIP + " 调焦停止成功!");},error: function () {showOPInfo(oWndInfo.szIP + "  调焦停止失败!");}});}
}function PTZFocusIn() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);if (oWndInfo != null) {WebVideoCtrl.I_PTZControl(12, false, {iWndIndex: g_iWndIndex,success: function (xmlDoc) {showOPInfo(oWndInfo.szIP + " 聚焦+成功!");},error: function () {showOPInfo(oWndInfo.szIP + "  聚焦+失败!");}});}
}function PTZFoucusOut() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);if (oWndInfo != null) {WebVideoCtrl.I_PTZControl(13, false, {iWndIndex: g_iWndIndex,success: function (xmlDoc) {showOPInfo(oWndInfo.szIP + " 聚焦-成功!");},error: function () {showOPInfo(oWndInfo.szIP + "  聚焦-失败!");}});}
}function PTZFoucusStop() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);if (oWndInfo != null) {WebVideoCtrl.I_PTZControl(12, true, {iWndIndex: g_iWndIndex,success: function (xmlDoc) {showOPInfo(oWndInfo.szIP + " 聚焦停止成功!");},error: function () {showOPInfo(oWndInfo.szIP + "  聚焦停止失败!");}});}
}function PTZIrisIn() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);if (oWndInfo != null) {WebVideoCtrl.I_PTZControl(14, false, {iWndIndex: g_iWndIndex,success: function (xmlDoc) {showOPInfo(oWndInfo.szIP + " 光圈+成功!");},error: function () {showOPInfo(oWndInfo.szIP + "  光圈+失败!");}});}
}function PTZIrisOut() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);if (oWndInfo != null) {WebVideoCtrl.I_PTZControl(15, false, {iWndIndex: g_iWndIndex,success: function (xmlDoc) {showOPInfo(oWndInfo.szIP + " 光圈-成功!");},error: function () {showOPInfo(oWndInfo.szIP + "  光圈-失败!");}});}
}function PTZIrisStop() {var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);if (oWndInfo != null) {WebVideoCtrl.I_PTZControl(14, true, {iWndIndex: g_iWndIndex,success: function (xmlDoc) {showOPInfo(oWndInfo.szIP + " 光圈停止成功!");},error: function () {showOPInfo(oWndInfo.szIP + "  光圈停止失败!");}});}
}dateFormat = function (oDate, fmt) {var o = {"M+": oDate.getMonth() + 1, //月份"d+": oDate.getDate(), //日"h+": oDate.getHours(), //小时"m+": oDate.getMinutes(), //分"s+": oDate.getSeconds(), //秒"q+": Math.floor((oDate.getMonth() + 3) / 3), //季度"S": oDate.getMilliseconds()//毫秒};if(/(y+)/.test(fmt)) {fmt = fmt.replace(RegExp.$1, (oDate.getFullYear() + "").substr(4 - RegExp.$1.length));}for (var k in o) {if(new RegExp("(" + k + ")").test(fmt)) {fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));}}return fmt;
};// 切换模式
function changeIPMode(iType) {var arrPort = [0, 7071, 80];$("#serverport").val(arrPort[iType]);
}// 获取设备IP
function clickGetDeviceIP() {var iDeviceMode = parseInt($("#devicemode").val(), 10),szAddress = $("#serveraddress").val(),iPort = parseInt($("#serverport").val(), 10) || 0,szDeviceID = $("#deviceid").val(),szDeviceInfo = "";szDeviceInfo = WebVideoCtrl.I_GetIPInfoByMode(iDeviceMode, szAddress, iPort, szDeviceID);if ("" == szDeviceInfo) {showOPInfo("设备IP和端口解析失败!");} else {showOPInfo("设备IP和端口解析成功!");var arrTemp = szDeviceInfo.split("-");$("#loginip").val(arrTemp[0]);$("#deviceport").val(arrTemp[1]);}
}
$(function () { //自动执行console.log('开始');clickLogin();changeWndNum();console.log('结束');
});

html调用内网海康威视摄像头相关推荐

  1. 如何访问内网的摄像头

    如何访问内网的摄像头? 手动 穿透内网 2010-10-12 21:39:18 分类: 系统运维 我有这样的一个需求.我在单位的机器上安装有摄像头.而单位是处于内网的.而我又不能控制网关.无法设置端口 ...

  2. (202103更新)海康威视网络摄像头sdk python版 (报错排查) 移动物体检测 多通道海康威视网洛摄像头后台检测 海康威视网络摄像头Python SDK

    海康威视网络摄像头Python SDK+移动物体位置检测 文末附 海康威视网络摄像头Python SDK 下载链接 本文参考博客 https://blog.csdn.net/c20081052/art ...

  3. Windows内网穿透

    使用inlets来实现 Windows && linux内网穿透 目的 工具获取 windows linux 环境准备 出口端配置(公网机器) python3启动测试(私有ip机器搭建 ...

  4. Centos和Window系统下Frp内网穿透

    frp 是一个高性能的内网穿透的反向代理软件,支持 TCP.UDP.HTTP.HTTPS 等常见协议(TCP最常用),可以将处于局域网或者家用电脑主机.办公电脑主机通过中转服务器的方式暴露在公网里,使 ...

  5. 海康威视摄像头自带网页自动登录

    想要在自己开发的网站中,内嵌海康威视摄像头的网页,在求助官方之后实现了在后台自动登录的功能: 尝试使用iframe内嵌时,尝试了完美解决Chrome Cookie SameSite跨站限制中的各种方法 ...

  6. 五、JAVA调用海康威视SDK实现摄像头内网转外网并前端展示

    接上一章:四.JAVA调用海康威视SDK实现摄像头内网推流到阿里云 本章实现摄像头内网推流到阿里云服务器并再浏览器WEB前端展示. 环境准备 开发工具:eclipse Jdk版本:jdk1.8 开发语 ...

  7. 基于opencv第三方视觉库,通过内网IP调用手机摄像头,实现人脸识别与图形监测

    1. 安装opencv视觉库 OpenCV 是一个开源的计算机视觉库,OpenCV 库用C语言和 C++ 语言编写,可以在 Windows.Linux.Mac OS X 等系统运行.同时也在积极开发 ...

  8. 海康威视RSTP摄像头视频数据从内网读取在web用HLS播放

    环境:海康威视录像机DS-7804NB-K1/4P,Ubuntu16.04 录像机内网地址192.168.100.99,一个摄像头接在4号口(32口以下通道号从33开始),摄像头内网地址 192.16 ...

  9. 内网web页面集成海康威视网络摄像头

    需求:公司内网的交换机(非海康威视平台),直接用网线将摄像头接入进来,然后将监控的画面实时的显示在内网web页面上. 海康威视开放平台音视频集成标准协议对接 https://open.hikvisio ...

最新文章

  1. JavaScript如何获得项目根路径
  2. Android实现系统关机和重启
  3. Python——反射
  4. windows一键安装web环境全攻略(win2008)
  5. JVM 内存区域大小参数设置
  6. python turtle画四叶草的步骤_python turtle工具绘制四叶草的实例分享
  7. static在内存层面的作用_C++内存管理笔记
  8. 【转】从TXT导入到dataGridView
  9. Windows 10 安装 scrapy 步骤
  10. Linux 中断学习之小试牛刀篇---Linux中断内核编程
  11. 手机qqsendencpac文件能删吗_无需任何app,手机电脑之前也能轻松传文件
  12. vector public member function
  13. linux 如何访问weblogic console,怎么修改weblogic console登陆的用户名和密码
  14. 证券交易1-交易系统简介
  15. aix显示服务器ip,AIX系统查看和设置网关和IP配置
  16. Linux为硬盘重建MBR,linux重建mbr
  17. JSON在线序列化网站
  18. 万年历源代码 c语言基础,C语言万年历的源程序
  19. mysql实现添加图片_如何往mysql中添加图片
  20. springboot整合阿里云短信验证(无需签名和模板,通过阿里云api测试实现短信验证)

热门文章

  1. @WebServlet需要引入的依赖包
  2. host文件编辑以后会被自动还原
  3. APNS苹果远程推送
  4. vagrant 说明
  5. 产品外观设计的特点和优点
  6. 前端常见面试题(四)
  7. IBM:gnuplot 让您的数据可视化 自由控制高级图表和数据绘图
  8. mysql undo mvvc_MySQL之MVVC原理
  9. 微软服务器名字,微软服务器软件名字最终敲定?
  10. Java类中变量初始化顺序