demo.js 70 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107
  1. // 初始化插件
  2. // 全局保存当前选中窗口
  3. var g_iWndIndex = 0; //可以不用设置这个变量,有窗口参数的接口中,不用传值,开发包会默认使用当前选择窗口
  4. var version="websdk3.220191023"
  5. $(function () {
  6. // 检查插件是否已经安装过
  7. var iRet = window.WebVideoCtrl.I_CheckPluginInstall();
  8. if (-1 == iRet) {
  9. alert("您还未安装过插件,双击开发包目录里的WebComponentsKit.exe安装!");
  10. return;
  11. }
  12. // 初始化插件参数及插入插件
  13. WebVideoCtrl.I_InitPlugin(500, 300, {
  14. bWndFull: true, //是否支持单窗口双击全屏,默认支持 true:支持 false:不支持
  15. iPackageType: 2,
  16. //szColorProperty:"plugin-background:0000ff; sub-background:0000ff; sub-border:00ffff; sub-border-select:0000ff", //2:PS 11:MP4
  17. iWndowType: 1,
  18. bNoPlugin: true,
  19. cbSelWnd: function (xmlDoc) {
  20. g_iWndIndex = parseInt($(xmlDoc).find("SelectWnd").eq(0).text(), 10);
  21. var szInfo = "当前选择的窗口编号:" + g_iWndIndex;
  22. showCBInfo(szInfo);
  23. },
  24. cbDoubleClickWnd: function (iWndIndex, bFullScreen) {
  25. var szInfo = "当前放大的窗口编号:" + iWndIndex;
  26. if (!bFullScreen) {
  27. szInfo = "当前还原的窗口编号:" + iWndIndex;
  28. }
  29. showCBInfo(szInfo);
  30. },
  31. cbEvent: function (iEventType, iParam1, iParam2) {
  32. if (2 == iEventType) {// 回放正常结束
  33. showCBInfo("窗口" + iParam1 + "回放结束!");
  34. } else if (-1 == iEventType) {
  35. showCBInfo("设备" + iParam1 + "网络错误!");
  36. } else if (3001 == iEventType) {
  37. clickStopRecord(g_szRecordType, iParam1);
  38. }
  39. },
  40. cbRemoteConfig: function () {
  41. showCBInfo("关闭远程配置库!");
  42. },
  43. cbInitPluginComplete: function () {
  44. WebVideoCtrl.I_InsertOBJECTPlugin("divPlugin");
  45. // 检查插件是否最新
  46. if (-1 == WebVideoCtrl.I_CheckPluginVersion()) {
  47. alert("检测到新的插件版本,双击开发包目录里的WebComponentsKit.exe升级!");
  48. return;
  49. }
  50. }
  51. });
  52. // 窗口事件绑定
  53. $(window).bind({
  54. resize: function () {
  55. // WebVideoCtrl.I_Resize($("body").width(), $("body").height());
  56. }
  57. });
  58. //初始化日期时间
  59. var szCurTime = dateFormat(new Date(), "yyyy-MM-dd");
  60. $("#starttime").val(szCurTime + " 00:00:00");
  61. $("#endtime").val(szCurTime + " 23:59:59");
  62. $("#downloadstarttime").val(szCurTime + " 00:00:00");
  63. $("#downloadendtime").val(szCurTime + " 23:59:59");
  64. if(WebVideoCtrl.I_SupportNoPlugin()){
  65. $(".localconfig").hide();
  66. $(".ipparse").hide();
  67. $("#checkVersion").hide();
  68. $("#remoteconfig").hide();
  69. $("#btnReverse").hide();
  70. $("#btnReverse").show();
  71. }
  72. else{
  73. // $("#fullbtn").hide();
  74. }
  75. });
  76. // 显示操作信息
  77. function showOPInfo(szInfo, status, xmlDoc) {
  78. var szTip = "<div>" + dateFormat(new Date(), "yyyy-MM-dd hh:mm:ss") + " " + szInfo;
  79. if (typeof status != "undefined" && status != 200) {
  80. var szStatusString = $(xmlDoc).find("statusString").eq(0).text();
  81. var szSubStatusCode = $(xmlDoc).find("subStatusCode").eq(0).text();
  82. if ("" === szSubStatusCode) {
  83. if("" === szSubStatusCode && "" === szStatusString){
  84. szTip += "(" + status + ")";
  85. }
  86. else{
  87. szTip += "(" + status + ", " + szStatusString + ")";
  88. }
  89. } else {
  90. szTip += "(" + status + ", " + szSubStatusCode + ")";
  91. }
  92. }
  93. szTip += "</div>";
  94. $("#opinfo").html(szTip + $("#opinfo").html());
  95. }
  96. // 显示回调信息
  97. function showCBInfo(szInfo) {
  98. szInfo = "<div>" + dateFormat(new Date(), "yyyy-MM-dd hh:mm:ss") + " " + szInfo + "</div>";
  99. $("#cbinfo").html(szInfo + $("#cbinfo").html());
  100. }
  101. // 格式化时间
  102. function dateFormat(oDate, fmt) {
  103. var o = {
  104. "M+": oDate.getMonth() + 1, //月份
  105. "d+": oDate.getDate(), //日
  106. "h+": oDate.getHours(), //小时
  107. "m+": oDate.getMinutes(), //分
  108. "s+": oDate.getSeconds(), //秒
  109. "q+": Math.floor((oDate.getMonth() + 3) / 3), //季度
  110. "S": oDate.getMilliseconds()//毫秒
  111. };
  112. if (/(y+)/.test(fmt)) {
  113. fmt = fmt.replace(RegExp.$1, (oDate.getFullYear() + "").substr(4 - RegExp.$1.length));
  114. }
  115. for (var k in o) {
  116. if (new RegExp("(" + k + ")").test(fmt)) {
  117. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  118. }
  119. }
  120. return fmt;
  121. }
  122. // 获取窗口尺寸
  123. function getWindowSize() {
  124. var nWidth = $(this).width() + $(this).scrollLeft(),
  125. nHeight = $(this).height() + $(this).scrollTop();
  126. return {width: nWidth, height: nHeight};
  127. }
  128. // 打开选择框 0:文件夹 1:文件
  129. function clickOpenFileDlg(id, iType) {
  130. WebVideoCtrl.I2_OpenFileDlg(iType).then(function(szDirPath){
  131. if (szDirPath != -1 && szDirPath != "" && szDirPath != null) {
  132. $("#" + id).val(szDirPath);
  133. }
  134. });
  135. }
  136. // 获取本地参数
  137. function clickGetLocalCfg() {
  138. var xmlDoc = WebVideoCtrl.I_GetLocalCfg();
  139. if (xmlDoc != null) {
  140. $("#netsPreach").val($(xmlDoc).find("BuffNumberType").eq(0).text());
  141. $("#wndSize").val($(xmlDoc).find("PlayWndType").eq(0).text());
  142. $("#rulesInfo").val($(xmlDoc).find("IVSMode").eq(0).text());
  143. $("#captureFileFormat").val($(xmlDoc).find("CaptureFileFormat").eq(0).text());
  144. $("#packSize").val($(xmlDoc).find("PackgeSize").eq(0).text());
  145. $("#recordPath").val($(xmlDoc).find("RecordPath").eq(0).text());
  146. $("#downloadPath").val($(xmlDoc).find("DownloadPath").eq(0).text());
  147. $("#previewPicPath").val($(xmlDoc).find("CapturePath").eq(0).text());
  148. $("#playbackPicPath").val($(xmlDoc).find("PlaybackPicPath").eq(0).text());
  149. $("#devicePicPath").val($(xmlDoc).find("DeviceCapturePath").eq(0).text());
  150. $("#playbackFilePath").val($(xmlDoc).find("PlaybackFilePath").eq(0).text());
  151. $("#protocolType").val($(xmlDoc).find("ProtocolType").eq(0).text());
  152. showOPInfo("本地配置获取成功!");
  153. } else {
  154. showOPInfo("本地配置获取失败!");
  155. }
  156. }
  157. // 设置本地参数
  158. function clickSetLocalCfg() {
  159. var arrXml = [],
  160. szInfo = "";
  161. arrXml.push("<LocalConfigInfo>");
  162. arrXml.push("<PackgeSize>" + $("#packSize").val() + "</PackgeSize>");
  163. arrXml.push("<PlayWndType>" + $("#wndSize").val() + "</PlayWndType>");
  164. arrXml.push("<BuffNumberType>" + $("#netsPreach").val() + "</BuffNumberType>");
  165. arrXml.push("<RecordPath>" + $("#recordPath").val() + "</RecordPath>");
  166. arrXml.push("<CapturePath>" + $("#previewPicPath").val() + "</CapturePath>");
  167. arrXml.push("<PlaybackFilePath>" + $("#playbackFilePath").val() + "</PlaybackFilePath>");
  168. arrXml.push("<PlaybackPicPath>" + $("#playbackPicPath").val() + "</PlaybackPicPath>");
  169. arrXml.push("<DeviceCapturePath>" + $("#devicePicPath").val() + "</DeviceCapturePath>");
  170. arrXml.push("<DownloadPath>" + $("#downloadPath").val() + "</DownloadPath>");
  171. arrXml.push("<IVSMode>" + $("#rulesInfo").val() + "</IVSMode>");
  172. arrXml.push("<CaptureFileFormat>" + $("#captureFileFormat").val() + "</CaptureFileFormat>");
  173. arrXml.push("<ProtocolType>" + $("#protocolType").val() + "</ProtocolType>");
  174. arrXml.push("</LocalConfigInfo>");
  175. var iRet = WebVideoCtrl.I_SetLocalCfg(arrXml.join(""));
  176. if (0 == iRet) {
  177. szInfo = "本地配置设置成功!";
  178. } else {
  179. szInfo = "本地配置设置失败!";
  180. }
  181. showOPInfo(szInfo);
  182. }
  183. // 窗口分割数
  184. function changeWndNum(iType) {
  185. iType = parseInt(iType, 10);
  186. WebVideoCtrl.I_ChangeWndNum(iType);
  187. }
  188. // 登录
  189. function clickLogin() {
  190. var szIP = $("#loginip").val(),
  191. szPort = $("#port").val(),
  192. szUsername = $("#username").val(),
  193. szPassword = $("#password").val();
  194. if ("" == szIP || "" == szPort) {
  195. return;
  196. }
  197. var szDeviceIdentify = szIP + "_" + szPort;
  198. var iRet = WebVideoCtrl.I_Login(szIP, 1, szPort, szUsername, szPassword, {
  199. success: function (xmlDoc) {
  200. showOPInfo(szDeviceIdentify + " 登录成功!");
  201. $("#ip").prepend("<option value='" + szDeviceIdentify + "'>" + szDeviceIdentify + "</option>");
  202. setTimeout(function () {
  203. $("#ip").val(szDeviceIdentify);
  204. getChannelInfo();
  205. getDevicePort();
  206. }, 10);
  207. },
  208. error: function (status, xmlDoc) {
  209. showOPInfo(szDeviceIdentify + " 登录失败!", status, xmlDoc);
  210. }
  211. });
  212. if (-1 == iRet) {
  213. showOPInfo(szDeviceIdentify + " 已登录过!");
  214. }
  215. }
  216. // 退出
  217. function clickLogout() {
  218. var szDeviceIdentify = $("#ip").val(),
  219. szInfo = "";
  220. if (null == szDeviceIdentify) {
  221. return;
  222. }
  223. var iRet = WebVideoCtrl.I_Logout(szDeviceIdentify);
  224. if (0 == iRet) {
  225. szInfo = "退出成功!";
  226. $("#ip option[value='" + szDeviceIdentify + "']").remove();
  227. getChannelInfo();
  228. getDevicePort();
  229. } else {
  230. szInfo = "退出失败!";
  231. }
  232. showOPInfo(szDeviceIdentify + " " + szInfo);
  233. }
  234. // 获取设备信息
  235. function clickGetDeviceInfo() {
  236. var szDeviceIdentify = $("#ip").val();
  237. if (null == szDeviceIdentify) {
  238. return;
  239. }
  240. WebVideoCtrl.I_GetDeviceInfo(szDeviceIdentify, {
  241. success: function (xmlDoc) {
  242. var arrStr = [];
  243. arrStr.push("设备名称:" + $(xmlDoc).find("deviceName").eq(0).text() + "\r\n");
  244. arrStr.push("设备ID:" + $(xmlDoc).find("deviceID").eq(0).text() + "\r\n");
  245. arrStr.push("型号:" + $(xmlDoc).find("model").eq(0).text() + "\r\n");
  246. arrStr.push("设备序列号:" + $(xmlDoc).find("serialNumber").eq(0).text() + "\r\n");
  247. arrStr.push("MAC地址:" + $(xmlDoc).find("macAddress").eq(0).text() + "\r\n");
  248. arrStr.push("主控版本:" + $(xmlDoc).find("firmwareVersion").eq(0).text() + " " + $(xmlDoc).find("firmwareReleasedDate").eq(0).text() + "\r\n");
  249. arrStr.push("编码版本:" + $(xmlDoc).find("encoderVersion").eq(0).text() + " " + $(xmlDoc).find("encoderReleasedDate").eq(0).text() + "\r\n");
  250. showOPInfo(szDeviceIdentify + " 获取设备信息成功!");
  251. alert(arrStr.join(""));
  252. },
  253. error: function (status, xmlDoc) {
  254. showOPInfo(szDeviceIdentify + " 获取设备信息失败!", status, xmlDoc);
  255. }
  256. });
  257. }
  258. // 获取通道
  259. function getChannelInfo() {
  260. var szDeviceIdentify = $("#ip").val(),
  261. oSel = $("#channels").empty();
  262. if (null == szDeviceIdentify) {
  263. return;
  264. }
  265. // 模拟通道
  266. WebVideoCtrl.I_GetAnalogChannelInfo(szDeviceIdentify, {
  267. async: false,
  268. success: function (xmlDoc) {
  269. var oChannels = $(xmlDoc).find("VideoInputChannel");
  270. $.each(oChannels, function (i) {
  271. var id = $(this).find("id").eq(0).text(),
  272. name = $(this).find("name").eq(0).text();
  273. if ("" == name) {
  274. name = "Camera " + (i < 9 ? "0" + (i + 1) : (i + 1));
  275. }
  276. oSel.append("<option value='" + id + "' bZero='false'>" + name + "</option>");
  277. });
  278. showOPInfo(szDeviceIdentify + " 获取模拟通道成功!");
  279. },
  280. error: function (status, xmlDoc) {
  281. showOPInfo(szDeviceIdentify + " 获取模拟通道失败!", status, xmlDoc);
  282. }
  283. });
  284. // 数字通道
  285. WebVideoCtrl.I_GetDigitalChannelInfo(szDeviceIdentify, {
  286. async: false,
  287. success: function (xmlDoc) {
  288. var oChannels = $(xmlDoc).find("InputProxyChannelStatus");
  289. $.each(oChannels, function (i) {
  290. var id = $(this).find("id").eq(0).text(),
  291. name = $(this).find("name").eq(0).text(),
  292. online = $(this).find("online").eq(0).text();
  293. if ("false" == online) {// 过滤禁用的数字通道
  294. return true;
  295. }
  296. if ("" == name) {
  297. name = "IPCamera " + (i < 9 ? "0" + (i + 1) : (i + 1));
  298. }
  299. oSel.append("<option value='" + id + "' bZero='false'>" + name + "</option>");
  300. });
  301. showOPInfo(szDeviceIdentify + " 获取数字通道成功!");
  302. },
  303. error: function (status, xmlDoc) {
  304. showOPInfo(szDeviceIdentify + " 获取数字通道失败!", status, xmlDoc);
  305. }
  306. });
  307. // 零通道
  308. WebVideoCtrl.I_GetZeroChannelInfo(szDeviceIdentify, {
  309. async: false,
  310. success: function (xmlDoc) {
  311. var oChannels = $(xmlDoc).find("ZeroVideoChannel");
  312. $.each(oChannels, function (i) {
  313. var id = $(this).find("id").eq(0).text(),
  314. name = $(this).find("name").eq(0).text();
  315. if ("" == name) {
  316. name = "Zero Channel " + (i < 9 ? "0" + (i + 1) : (i + 1));
  317. }
  318. if ("true" == $(this).find("enabled").eq(0).text()) {// 过滤禁用的零通道
  319. oSel.append("<option value='" + id + "' bZero='true'>" + name + "</option>");
  320. }
  321. });
  322. showOPInfo(szDeviceIdentify + " 获取零通道成功!");
  323. },
  324. error: function (status, xmlDoc) {
  325. showOPInfo(szDeviceIdentify + " 获取零通道失败!", status, xmlDoc);
  326. }
  327. });
  328. }
  329. // 获取端口
  330. function getDevicePort() {
  331. var szDeviceIdentify = $("#ip").val();
  332. if (null == szDeviceIdentify) {
  333. return;
  334. }
  335. var oPort = WebVideoCtrl.I_GetDevicePort(szDeviceIdentify);
  336. if (oPort != null) {
  337. $("#deviceport").val(oPort.iDevicePort);
  338. $("#rtspport").val(oPort.iRtspPort);
  339. showOPInfo(szDeviceIdentify + " 获取端口成功!");
  340. } else {
  341. showOPInfo(szDeviceIdentify + " 获取端口失败!");
  342. }
  343. }
  344. // 获取数字通道
  345. function clickGetDigitalChannelInfo() {
  346. var szDeviceIdentify = $("#ip").val(),
  347. iAnalogChannelNum = 0;
  348. $("#digitalchannellist").empty();
  349. if (null == szDeviceIdentify) {
  350. return;
  351. }
  352. // 模拟通道
  353. WebVideoCtrl.I_GetAnalogChannelInfo(szDeviceIdentify, {
  354. async: false,
  355. success: function (xmlDoc) {
  356. iAnalogChannelNum = $(xmlDoc).find("VideoInputChannel").length;
  357. },
  358. error: function () {
  359. }
  360. });
  361. // 数字通道
  362. WebVideoCtrl.I_GetDigitalChannelInfo(szDeviceIdentify, {
  363. async: false,
  364. success: function (xmlDoc) {
  365. var oChannels = $(xmlDoc).find("InputProxyChannelStatus");
  366. $.each(oChannels, function () {
  367. var id = parseInt($(this).find("id").eq(0).text(), 10),
  368. ipAddress = $(this).find("ipAddress").eq(0).text(),
  369. srcInputPort = $(this).find("srcInputPort").eq(0).text(),
  370. managePortNo = $(this).find("managePortNo").eq(0).text(),
  371. online = $(this).find("online").eq(0).text(),
  372. proxyProtocol = $(this).find("proxyProtocol").eq(0).text();
  373. var objTr = $("#digitalchannellist").get(0).insertRow(-1);
  374. var objTd = objTr.insertCell(0);
  375. objTd.innerHTML = (id - iAnalogChannelNum) < 10 ? "D0" + (id - iAnalogChannelNum) : "D" + (id - iAnalogChannelNum);
  376. objTd = objTr.insertCell(1);
  377. objTd.width = "25%";
  378. objTd.innerHTML = ipAddress;
  379. objTd = objTr.insertCell(2);
  380. objTd.width = "15%";
  381. objTd.innerHTML = srcInputPort;
  382. objTd = objTr.insertCell(3);
  383. objTd.width = "20%";
  384. objTd.innerHTML = managePortNo;
  385. objTd = objTr.insertCell(4);
  386. objTd.width = "15%";
  387. objTd.innerHTML = "true" == online ? "在线" : "离线";
  388. objTd = objTr.insertCell(5);
  389. objTd.width = "25%";
  390. objTd.innerHTML = proxyProtocol;
  391. });
  392. showOPInfo(szDeviceIdentify + " 获取数字通道成功!");
  393. },
  394. error: function (status, xmlDoc) {
  395. showOPInfo(szDeviceIdentify + " 没有数字通道!", status, xmlDoc);
  396. }
  397. });
  398. }
  399. // 开始预览
  400. function clickStartRealPlay(iStreamType) {
  401. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  402. szDeviceIdentify = $("#ip").val(),
  403. iRtspPort = parseInt($("#rtspport").val(), 10),
  404. iChannelID = parseInt($("#channels").val(), 10),
  405. bZeroChannel = $("#channels option").eq($("#channels").get(0).selectedIndex).attr("bZero") == "true" ? true : false,
  406. szInfo = "";
  407. if ("undefined" === typeof iStreamType) {
  408. iStreamType = parseInt($("#streamtype").val(), 10);
  409. }
  410. if (null == szDeviceIdentify) {
  411. return;
  412. }
  413. var startRealPlay = function () {
  414. WebVideoCtrl.I_StartRealPlay(szDeviceIdentify, {
  415. iRtspPort: iRtspPort,
  416. iStreamType: iStreamType,
  417. iChannelID: iChannelID,
  418. bZeroChannel: bZeroChannel,
  419. success: function () {
  420. szInfo = "开始预览成功!";
  421. showOPInfo(szDeviceIdentify + " " + szInfo);
  422. },
  423. error: function (status, xmlDoc) {
  424. if (403 === status) {
  425. szInfo = "设备不支持Websocket取流!";
  426. } else {
  427. szInfo = "开始预览失败!";
  428. }
  429. showOPInfo(szDeviceIdentify + " " + szInfo);
  430. }
  431. });
  432. };
  433. if (oWndInfo != null) {// 已经在播放了,先停止
  434. WebVideoCtrl.I_Stop({
  435. success: function () {
  436. startRealPlay();
  437. }
  438. });
  439. } else {
  440. startRealPlay();
  441. }
  442. }
  443. function setTextOverlay() {
  444. var szDeviceIdentify = $("#ip").val();
  445. var szInfo = "";
  446. var that = this;
  447. var iChannelID = parseInt($("#channels").val(), 10);
  448. var szUrl = "ISAPI/System/Video/inputs/channels/" + iChannelID + "/overlays";
  449. WebVideoCtrl.I_GetTextOverlay(szUrl,szDeviceIdentify,{
  450. success:function(data){
  451. $(data).find("TextOverlay").eq(0).find("displayText").eq(0).text("eee6444是66ee&lt;");
  452. $(data).find("TextOverlay").eq(0).find("positionX").eq(0).text("20");
  453. $(data).find("TextOverlay").eq(0).find("positionY").eq(0).text("30");
  454. var xmldoc = toXMLStr(data);
  455. var newOptions = {
  456. async:true,
  457. type: "PUT",
  458. data:xmldoc,
  459. success:function(){
  460. szInfo = "绘制osd信息成功";
  461. showOPInfo(szDeviceIdentify + " " + szInfo);
  462. },
  463. error:function(){
  464. szInfo = "绘制osd信息失败";
  465. showOPInfo(szDeviceIdentify + " " + szInfo);
  466. }
  467. };
  468. WebVideoCtrl.I_SendHTTPRequest(szDeviceIdentify,szUrl,newOptions);
  469. },
  470. error:function(){
  471. szInfo = "获取osd信息失败";
  472. showOPInfo(szDeviceIdentify + " " + szInfo);
  473. }
  474. });
  475. }
  476. // 停止预览
  477. function clickStopRealPlay() {
  478. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  479. szInfo = "";
  480. if (oWndInfo != null) {
  481. WebVideoCtrl.I_Stop({
  482. success: function () {
  483. szInfo = "停止预览成功!";
  484. showOPInfo(oWndInfo.szDeviceIdentify + " " + szInfo);
  485. },
  486. error: function () {
  487. szInfo = "停止预览失败!";
  488. showOPInfo(oWndInfo.szDeviceIdentify + " " + szInfo);
  489. }
  490. });
  491. }
  492. }
  493. // 打开声音
  494. function clickOpenSound() {
  495. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  496. szInfo = "";
  497. if (oWndInfo != null) {
  498. var allWndInfo = WebVideoCtrl.I_GetWindowStatus();
  499. // 循环遍历所有窗口,如果有窗口打开了声音,先关闭
  500. for (var i = 0, iLen = allWndInfo.length; i < iLen; i++) {
  501. oWndInfo = allWndInfo[i];
  502. if (oWndInfo.bSound) {
  503. WebVideoCtrl.I_CloseSound(oWndInfo.iIndex);
  504. break;
  505. }
  506. }
  507. var iRet = WebVideoCtrl.I_OpenSound();
  508. if (0 == iRet) {
  509. szInfo = "打开声音成功!";
  510. } else {
  511. szInfo = "打开声音失败!";
  512. }
  513. showOPInfo(oWndInfo.szDeviceIdentify + " " + szInfo);
  514. }
  515. }
  516. // 关闭声音
  517. function clickCloseSound() {
  518. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  519. szInfo = "";
  520. if (oWndInfo != null) {
  521. var iRet = WebVideoCtrl.I_CloseSound();
  522. if (0 == iRet) {
  523. szInfo = "关闭声音成功!";
  524. } else {
  525. szInfo = "关闭声音失败!";
  526. }
  527. showOPInfo(oWndInfo.szDeviceIdentify + " " + szInfo);
  528. }
  529. }
  530. // 设置音量
  531. function clickSetVolume() {
  532. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  533. iVolume = parseInt($("#volume").val(), 10),
  534. szInfo = "";
  535. if (oWndInfo != null) {
  536. var iRet = WebVideoCtrl.I_SetVolume(iVolume);
  537. if (0 == iRet) {
  538. szInfo = "音量设置成功!";
  539. } else {
  540. szInfo = "音量设置失败!";
  541. }
  542. showOPInfo(oWndInfo.szDeviceIdentify + " " + szInfo);
  543. }
  544. }
  545. // 抓图
  546. function clickCapturePic() {
  547. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  548. szInfo = "";
  549. if (oWndInfo != null) {
  550. var xmlDoc = WebVideoCtrl.I_GetLocalCfg();
  551. var szCaptureFileFormat = "0";
  552. if (xmlDoc != null) {
  553. szCaptureFileFormat = $(xmlDoc).find("CaptureFileFormat").eq(0).text();
  554. }
  555. var szChannelID = $("#channels").val();
  556. var szPicName = oWndInfo.szDeviceIdentify + "_" + szChannelID + "_" + new Date().getTime();
  557. szPicName += ("0" === szCaptureFileFormat) ? ".jpg": ".bmp";
  558. WebVideoCtrl.I2_CapturePic(szPicName, {
  559. bDateDir: true //是否生成日期文件
  560. }).then(function(){
  561. szInfo = "抓图成功!";
  562. showOPInfo(oWndInfo.szDeviceIdentify + " " + szInfo);
  563. },function(){
  564. szInfo = "抓图失败!";
  565. showOPInfo(oWndInfo.szDeviceIdentify + " " + szInfo);
  566. });
  567. }
  568. }
  569. // 抓图
  570. function clickCapturePicData() {
  571. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  572. szInfo = "";
  573. if (oWndInfo != null) {
  574. WebVideoCtrl.I2_CapturePicData().then(function(data){
  575. szInfo = "抓图上传成功!";
  576. console.log(data);
  577. showOPInfo(oWndInfo.szDeviceIdentify + " " + szInfo);
  578. },function(){
  579. szInfo = "抓图失败!";
  580. showOPInfo(oWndInfo.szDeviceIdentify + " " + szInfo);
  581. });
  582. }
  583. }
  584. // 开始录像
  585. var g_szRecordType = "";
  586. function clickStartRecord(szType) {
  587. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  588. szInfo = "";
  589. g_szRecordType = szType;
  590. if (oWndInfo != null) {
  591. var szChannelID = $("#channels").val(),
  592. szFileName = oWndInfo.szDeviceIdentify + "_" + szChannelID + "_" + new Date().getTime();
  593. WebVideoCtrl.I_StartRecord(szFileName, {
  594. bDateDir: true, //是否生成日期文件
  595. success: function () {
  596. if ('realplay' === szType) {
  597. szInfo = "开始录像成功!";
  598. } else if ('playback' === szType) {
  599. szInfo = "开始剪辑成功!";
  600. }
  601. showOPInfo(oWndInfo.szDeviceIdentify + " " + szInfo);
  602. },
  603. error: function () {
  604. if ('realplay' === szType) {
  605. szInfo = "开始录像失败!";
  606. } else if ('playback' === szType) {
  607. szInfo = "开始剪辑失败!";
  608. }
  609. showOPInfo(oWndInfo.szDeviceIdentify + " " + szInfo);
  610. }
  611. });
  612. }
  613. }
  614. // 停止录像
  615. function clickStopRecord(szType, iWndIndex) {
  616. if ("undefined" === typeof iWndIndex) {
  617. iWndIndex = g_iWndIndex;
  618. }
  619. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(iWndIndex),
  620. szInfo = "";
  621. if (oWndInfo != null) {
  622. WebVideoCtrl.I_StopRecord({
  623. success: function () {
  624. if ('realplay' === szType) {
  625. szInfo = "停止录像成功!";
  626. } else if ('playback' === szType) {
  627. szInfo = "停止剪辑成功!";
  628. }
  629. showOPInfo(oWndInfo.szDeviceIdentify + " " + szInfo);
  630. },
  631. error: function () {
  632. if ('realplay' === szType) {
  633. szInfo = "停止录像失败!";
  634. } else if ('playback' === szType) {
  635. szInfo = "停止剪辑失败!";
  636. }
  637. showOPInfo(oWndInfo.szDeviceIdentify + " " + szInfo);
  638. }
  639. });
  640. }
  641. }
  642. // 获取对讲通道
  643. function clickGetAudioInfo() {
  644. var szDeviceIdentify = $("#ip").val();
  645. if (null == szDeviceIdentify) {
  646. return;
  647. }
  648. WebVideoCtrl.I_GetAudioInfo(szDeviceIdentify, {
  649. success: function (xmlDoc) {
  650. var oAudioChannels = $(xmlDoc).find("TwoWayAudioChannel"),
  651. oSel = $("#audiochannels").empty();
  652. $.each(oAudioChannels, function () {
  653. var id = $(this).find("id").eq(0).text();
  654. oSel.append("<option value='" + id + "'>" + id + "</option>");
  655. });
  656. showOPInfo(szDeviceIdentify + " 获取对讲通道成功!");
  657. },
  658. error: function (status, xmlDoc) {
  659. showOPInfo(szDeviceIdentify + " 获取对讲通道失败!", status, xmlDoc);
  660. }
  661. });
  662. }
  663. // 开始对讲
  664. function clickStartVoiceTalk() {
  665. var szDeviceIdentify = $("#ip").val(),
  666. iAudioChannel = parseInt($("#audiochannels").val(), 10),
  667. szInfo = "";
  668. if (null == szDeviceIdentify) {
  669. return;
  670. }
  671. if (isNaN(iAudioChannel)) {
  672. alert("请选择对讲通道!");
  673. return;
  674. }
  675. var iRet = WebVideoCtrl.I_StartVoiceTalk(szDeviceIdentify, iAudioChannel);
  676. if (0 == iRet) {
  677. szInfo = "开始对讲成功!";
  678. } else {
  679. szInfo = "开始对讲失败!";
  680. }
  681. showOPInfo(szDeviceIdentify + " " + szInfo);
  682. }
  683. // 停止对讲
  684. function clickStopVoiceTalk() {
  685. var szDeviceIdentify = $("#ip").val(),
  686. iRet = WebVideoCtrl.I_StopVoiceTalk(),
  687. szInfo = "";
  688. if (null == szDeviceIdentify) {
  689. return;
  690. }
  691. if (0 == iRet) {
  692. szInfo = "停止对讲成功!";
  693. } else {
  694. szInfo = "停止对讲失败!";
  695. }
  696. showOPInfo(szDeviceIdentify + " " + szInfo);
  697. }
  698. // 启用电子放大
  699. function clickEnableEZoom() {
  700. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  701. szInfo = "";
  702. if (oWndInfo != null) {
  703. var iRet = WebVideoCtrl.I_EnableEZoom();
  704. if (0 == iRet) {
  705. szInfo = "启用电子放大成功!";
  706. } else {
  707. szInfo = "启用电子放大失败!";
  708. }
  709. showOPInfo(oWndInfo.szDeviceIdentify + " " + szInfo);
  710. }
  711. }
  712. // 禁用电子放大
  713. function clickDisableEZoom() {
  714. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  715. szInfo = "";
  716. if (oWndInfo != null) {
  717. var iRet = WebVideoCtrl.I_DisableEZoom();
  718. if (0 == iRet) {
  719. szInfo = "禁用电子放大成功!";
  720. } else {
  721. szInfo = "禁用电子放大失败!";
  722. }
  723. showOPInfo(oWndInfo.szDeviceIdentify + " " + szInfo);
  724. }
  725. }
  726. // 启用3D放大
  727. function clickEnable3DZoom() {
  728. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  729. szInfo = "";
  730. if (oWndInfo != null) {
  731. var iRet = WebVideoCtrl.I_Enable3DZoom();
  732. if (0 == iRet) {
  733. szInfo = "启用3D放大成功!";
  734. } else {
  735. szInfo = "启用3D放大失败!";
  736. }
  737. showOPInfo(oWndInfo.szDeviceIdentify + " " + szInfo);
  738. }
  739. }
  740. // 禁用3D放大
  741. function clickDisable3DZoom() {
  742. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  743. szInfo = "";
  744. if (oWndInfo != null) {
  745. var iRet = WebVideoCtrl.I_Disable3DZoom();
  746. if (0 == iRet) {
  747. szInfo = "禁用3D放大成功!";
  748. } else {
  749. szInfo = "禁用3D放大失败!";
  750. }
  751. showOPInfo(oWndInfo.szDeviceIdentify + " " + szInfo);
  752. }
  753. }
  754. // 全屏
  755. function clickFullScreen() {
  756. WebVideoCtrl.I_FullScreen(true);
  757. }
  758. // PTZ控制 9为自动,1,2,3,4,5,6,7,8为方向PTZ
  759. var g_bPTZAuto = false;
  760. function mouseDownPTZControl(iPTZIndex) {
  761. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  762. bZeroChannel = $("#channels option").eq($("#channels").get(0).selectedIndex).attr("bZero") == "true" ? true : false,
  763. iPTZSpeed = $("#ptzspeed").val();
  764. if (bZeroChannel) {// 零通道不支持云台
  765. return;
  766. }
  767. if (oWndInfo != null) {
  768. if (9 == iPTZIndex && g_bPTZAuto) {
  769. iPTZSpeed = 0;// 自动开启后,速度置为0可以关闭自动
  770. } else {
  771. g_bPTZAuto = false;// 点击其他方向,自动肯定会被关闭
  772. }
  773. WebVideoCtrl.I_PTZControl(iPTZIndex, false, {
  774. iPTZSpeed: iPTZSpeed,
  775. success: function (xmlDoc) {
  776. if (9 == iPTZIndex && g_bPTZAuto) {
  777. showOPInfo(oWndInfo.szDeviceIdentify + " 停止云台成功!");
  778. } else {
  779. showOPInfo(oWndInfo.szDeviceIdentify + " 开启云台成功!");
  780. }
  781. if (9 == iPTZIndex) {
  782. g_bPTZAuto = !g_bPTZAuto;
  783. }
  784. },
  785. error: function (status, xmlDoc) {
  786. showOPInfo(oWndInfo.szDeviceIdentify + " 开启云台失败!", status, xmlDoc);
  787. }
  788. });
  789. }
  790. }
  791. // 方向PTZ停止
  792. function mouseUpPTZControl() {
  793. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);
  794. if (oWndInfo != null) {
  795. WebVideoCtrl.I_PTZControl(1, true, {
  796. success: function (xmlDoc) {
  797. showOPInfo(oWndInfo.szDeviceIdentify + " 停止云台成功!");
  798. },
  799. error: function (status, xmlDoc) {
  800. showOPInfo(oWndInfo.szDeviceIdentify + " 停止云台失败!", status, xmlDoc);
  801. }
  802. });
  803. }
  804. }
  805. // 设置预置点
  806. function clickSetPreset() {
  807. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  808. iPresetID = parseInt($("#preset").val(), 10);
  809. if (oWndInfo != null) {
  810. WebVideoCtrl.I_SetPreset(iPresetID, {
  811. success: function (xmlDoc) {
  812. showOPInfo(oWndInfo.szDeviceIdentify + " 设置预置点成功!");
  813. },
  814. error: function (status, xmlDoc) {
  815. showOPInfo(oWndInfo.szDeviceIdentify + " 设置预置点失败!", status, xmlDoc);
  816. }
  817. });
  818. }
  819. }
  820. // 调用预置点
  821. function clickGoPreset() {
  822. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  823. iPresetID = parseInt($("#preset").val(), 10);
  824. if (oWndInfo != null) {
  825. WebVideoCtrl.I_GoPreset(iPresetID, {
  826. success: function (xmlDoc) {
  827. showOPInfo(oWndInfo.szDeviceIdentify + " 调用预置点成功!");
  828. },
  829. error: function (status, xmlDoc) {
  830. showOPInfo(oWndInfo.szDeviceIdentify + " 调用预置点失败!", status, xmlDoc);
  831. }
  832. });
  833. }
  834. }
  835. // 搜索录像
  836. var g_iSearchTimes = 0;
  837. function clickRecordSearch(iType) {
  838. var szDeviceIdentify = $("#ip").val(),
  839. iChannelID = parseInt($("#channels").val(), 10),
  840. bZeroChannel = $("#channels option").eq($("#channels").get(0).selectedIndex).attr("bZero") == "true" ? true : false,
  841. iStreamType = parseInt($("#record_streamtype").val(), 10),
  842. szStartTime = $("#starttime").val(),
  843. szEndTime = $("#endtime").val();
  844. if (Date.parse(szEndTime.replace(/-/g, "/")) - Date.parse(szStartTime.replace(/-/g, "/")) < 0) {
  845. alert("开始时间大于结束时间");
  846. return;
  847. }
  848. if (null == szDeviceIdentify) {
  849. return;
  850. }
  851. if (bZeroChannel) {// 零通道不支持录像搜索
  852. return;
  853. }
  854. if (0 == iType) {// 首次搜索
  855. $("#searchlist").empty();
  856. g_iSearchTimes = 0;
  857. }
  858. WebVideoCtrl.I_RecordSearch(szDeviceIdentify, iChannelID, szStartTime, szEndTime, {
  859. iStreamType: iStreamType,
  860. iSearchPos: g_iSearchTimes * 40,
  861. success: function (xmlDoc) {
  862. if ("MORE" === $(xmlDoc).find("responseStatusStrg").eq(0).text()) {
  863. for(var i = 0, nLen = $(xmlDoc).find("searchMatchItem").length; i < nLen; i++) {
  864. var szPlaybackURI = $(xmlDoc).find("playbackURI").eq(i).text();
  865. if(szPlaybackURI.indexOf("name=") < 0) {
  866. break;
  867. }
  868. var szStartTime = $(xmlDoc).find("startTime").eq(i).text();
  869. var szEndTime = $(xmlDoc).find("endTime").eq(i).text();
  870. var szFileName = szPlaybackURI.substring(szPlaybackURI.indexOf("name=") + 5, szPlaybackURI.indexOf("&size="));
  871. var objTr = $("#searchlist").get(0).insertRow(-1);
  872. var objTd = objTr.insertCell(0);
  873. objTd.id = "downloadTd" + i;
  874. objTd.innerHTML = g_iSearchTimes * 40 + (i + 1);
  875. objTd = objTr.insertCell(1);
  876. objTd.width = "30%";
  877. objTd.innerHTML = szFileName;
  878. objTd = objTr.insertCell(2);
  879. objTd.width = "30%";
  880. objTd.innerHTML = (szStartTime.replace("T", " ")).replace("Z", "");
  881. objTd = objTr.insertCell(3);
  882. objTd.width = "30%";
  883. objTd.innerHTML = (szEndTime.replace("T", " ")).replace("Z", "");
  884. objTd = objTr.insertCell(4);
  885. objTd.width = "10%";
  886. objTd.innerHTML = "<a href='javascript:;' onclick='clickStartDownloadRecord(" + (i + g_iSearchTimes * 40) + ");'>下载</a>";
  887. $("#downloadTd" + (i + g_iSearchTimes * 40)).data("fileName", szFileName);
  888. $("#downloadTd" + (i + g_iSearchTimes * 40)).data("playbackURI", szPlaybackURI);
  889. }
  890. g_iSearchTimes++;
  891. clickRecordSearch(1);// 继续搜索
  892. } else if ("OK" === $(xmlDoc).find("responseStatusStrg").eq(0).text()) {
  893. var iLength = $(xmlDoc).find("searchMatchItem").length;
  894. for(var i = 0; i < iLength; i++) {
  895. var szPlaybackURI = $(xmlDoc).find("playbackURI").eq(i).text();
  896. if(szPlaybackURI.indexOf("name=") < 0) {
  897. break;
  898. }
  899. var szStartTime = $(xmlDoc).find("startTime").eq(i).text();
  900. var szEndTime = $(xmlDoc).find("endTime").eq(i).text();
  901. var szFileName = szPlaybackURI.substring(szPlaybackURI.indexOf("name=") + 5, szPlaybackURI.indexOf("&size="));
  902. var objTr = $("#searchlist").get(0).insertRow(-1);
  903. var objTd = objTr.insertCell(0);
  904. objTd.id = "downloadTd" + i;
  905. objTd.innerHTML = g_iSearchTimes * 40 + (i + 1);
  906. objTd = objTr.insertCell(1);
  907. objTd.width = "30%";
  908. objTd.innerHTML = szFileName;
  909. objTd = objTr.insertCell(2);
  910. objTd.width = "30%";
  911. objTd.innerHTML = (szStartTime.replace("T", " ")).replace("Z", "");
  912. objTd = objTr.insertCell(3);
  913. objTd.width = "30%";
  914. objTd.innerHTML = (szEndTime.replace("T", " ")).replace("Z", "");
  915. objTd = objTr.insertCell(4);
  916. objTd.width = "10%";
  917. objTd.innerHTML = "<a href='javascript:;' onclick='clickStartDownloadRecord(" + (i + g_iSearchTimes * 40) + ");'>下载</a>";
  918. $("#downloadTd" + (i + g_iSearchTimes * 40)).data("fileName", szFileName);
  919. $("#downloadTd" + (i + g_iSearchTimes * 40)).data("playbackURI", szPlaybackURI);
  920. }
  921. showOPInfo(szDeviceIdentify + " 搜索录像文件成功!");
  922. } else if("NO MATCHES" === $(xmlDoc).find("responseStatusStrg").eq(0).text()) {
  923. setTimeout(function() {
  924. showOPInfo(szDeviceIdentify + " 没有录像文件!");
  925. }, 50);
  926. }
  927. },
  928. error: function (status, xmlDoc) {
  929. showOPInfo(szDeviceIdentify + " 搜索录像文件失败!", status, xmlDoc);
  930. }
  931. });
  932. }
  933. // 开始回放
  934. function clickStartPlayback() {
  935. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  936. szDeviceIdentify = $("#ip").val(),
  937. iRtspPort = parseInt($("#rtspport").val(), 10),
  938. iStreamType = parseInt($("#record_streamtype").val(), 10),
  939. bZeroChannel = $("#channels option").eq($("#channels").get(0).selectedIndex).attr("bZero") == "true" ? true : false,
  940. iChannelID = parseInt($("#channels").val(), 10),
  941. szStartTime = $("#starttime").val(),
  942. szEndTime = $("#endtime").val(),
  943. szInfo = "",
  944. bChecked = $("#transstream").prop("checked"),
  945. iRet = -1;
  946. if (null == szDeviceIdentify) {
  947. return;
  948. }
  949. if (bZeroChannel) {// 零通道不支持回放
  950. return;
  951. }
  952. var startPlayback = function () {
  953. if (bChecked) {// 启用转码回放
  954. var oTransCodeParam = {
  955. TransFrameRate: "14",// 0:全帧率,5:1,6:2,7:4,8:6,9:8,10:10,11:12,12:16,14:15,15:18,13:20,16:22
  956. TransResolution: "1",// 255:Auto,3:4CIF,2:QCIF,1:CIF
  957. TransBitrate: "19"// 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
  958. };
  959. WebVideoCtrl.I_StartPlayback(szDeviceIdentify, {
  960. iRtspPort: iRtspPort,
  961. iStreamType: iStreamType,
  962. iChannelID: iChannelID,
  963. szStartTime: szStartTime,
  964. szEndTime: szEndTime,
  965. oTransCodeParam: oTransCodeParam,
  966. success: function () {
  967. szInfo = "开始回放成功!";
  968. showOPInfo(szDeviceIdentify + " " + szInfo);
  969. },
  970. error: function (status, xmlDoc) {
  971. if (403 === status) {
  972. szInfo = "设备不支持Websocket取流!";
  973. } else {
  974. szInfo = "开始回放失败!";
  975. }
  976. showOPInfo(szDeviceIdentify + " " + szInfo);
  977. }
  978. });
  979. } else {
  980. WebVideoCtrl.I_StartPlayback(szDeviceIdentify, {
  981. iRtspPort: iRtspPort,
  982. iStreamType: iStreamType,
  983. iChannelID: iChannelID,
  984. szStartTime: szStartTime,
  985. szEndTime: szEndTime,
  986. success: function () {
  987. szInfo = "开始回放成功!";
  988. showOPInfo(szDeviceIdentify + " " + szInfo);
  989. },
  990. error: function (status, xmlDoc) {
  991. if (403 === status) {
  992. szInfo = "设备不支持Websocket取流!";
  993. } else {
  994. szInfo = "开始回放失败!";
  995. }
  996. showOPInfo(szDeviceIdentify + " " + szInfo);
  997. }
  998. });
  999. }
  1000. };
  1001. if (oWndInfo != null) {// 已经在播放了,先停止
  1002. WebVideoCtrl.I_Stop({
  1003. success: function () {
  1004. startPlayback();
  1005. }
  1006. });
  1007. } else {
  1008. startPlayback();
  1009. }
  1010. }
  1011. // 停止回放
  1012. function clickStopPlayback() {
  1013. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  1014. szInfo = "";
  1015. if (oWndInfo != null) {
  1016. WebVideoCtrl.I_Stop({
  1017. success: function () {
  1018. szInfo = "停止回放成功!";
  1019. showOPInfo(oWndInfo.szDeviceIdentify + " " + szInfo);
  1020. },
  1021. error: function () {
  1022. szInfo = "停止回放失败!";
  1023. showOPInfo(oWndInfo.szDeviceIdentify + " " + szInfo);
  1024. }
  1025. });
  1026. }
  1027. }
  1028. // 开始倒放
  1029. function clickReversePlayback() {
  1030. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  1031. szDeviceIdentify = $("#ip").val(),
  1032. iRtspPort = parseInt($("#rtspport").val(), 10),
  1033. iStreamType = parseInt($("#record_streamtype").val(), 10),
  1034. bZeroChannel = $("#channels option").eq($("#channels").get(0).selectedIndex).attr("bZero") == "true" ? true : false,
  1035. iChannelID = parseInt($("#channels").val(), 10),
  1036. szStartTime = $("#starttime").val(),
  1037. szEndTime = $("#endtime").val(),
  1038. szInfo = "";
  1039. if (null == szDeviceIdentify) {
  1040. return;
  1041. }
  1042. if (bZeroChannel) {// 零通道不支持倒放
  1043. return;
  1044. }
  1045. var reversePlayback = function () {
  1046. var iRet = WebVideoCtrl.I_ReversePlayback(szDeviceIdentify, {
  1047. iRtspPort: iRtspPort,
  1048. iStreamType: iStreamType,
  1049. iChannelID: iChannelID,
  1050. szStartTime: szStartTime,
  1051. szEndTime: szEndTime
  1052. });
  1053. if (0 == iRet) {
  1054. szInfo = "开始倒放成功!";
  1055. } else {
  1056. szInfo = "开始倒放失败!";
  1057. }
  1058. showOPInfo(szDeviceIdentify + " " + szInfo);
  1059. };
  1060. if (oWndInfo != null) {// 已经在播放了,先停止
  1061. WebVideoCtrl.I_Stop({
  1062. success: function () {
  1063. reversePlayback();
  1064. }
  1065. });
  1066. } else {
  1067. reversePlayback();
  1068. }
  1069. }
  1070. // 单帧
  1071. function clickFrame() {
  1072. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  1073. szInfo = "";
  1074. if (oWndInfo != null) {
  1075. WebVideoCtrl.I_Frame({
  1076. success: function () {
  1077. szInfo = "单帧播放成功!";
  1078. showOPInfo(oWndInfo.szDeviceIdentify + " " + szInfo);
  1079. },
  1080. error: function () {
  1081. szInfo = "单帧播放失败!";
  1082. showOPInfo(oWndInfo.szDeviceIdentify + " " + szInfo);
  1083. }
  1084. });
  1085. }
  1086. }
  1087. // 暂停
  1088. function clickPause() {
  1089. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  1090. szInfo = "";
  1091. if (oWndInfo != null) {
  1092. WebVideoCtrl.I_Pause({
  1093. success: function () {
  1094. szInfo = "暂停成功!";
  1095. showOPInfo(oWndInfo.szDeviceIdentify + " " + szInfo);
  1096. },
  1097. error: function () {
  1098. szInfo = "暂停失败!";
  1099. showOPInfo(oWndInfo.szDeviceIdentify + " " + szInfo);
  1100. }
  1101. });
  1102. }
  1103. }
  1104. // 恢复
  1105. function clickResume() {
  1106. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  1107. szInfo = "";
  1108. if (oWndInfo != null) {
  1109. WebVideoCtrl.I_Resume({
  1110. success: function () {
  1111. szInfo = "恢复成功!";
  1112. showOPInfo(oWndInfo.szDeviceIdentify + " " + szInfo);
  1113. },
  1114. error: function () {
  1115. szInfo = "恢复失败!";
  1116. showOPInfo(oWndInfo.szDeviceIdentify + " " + szInfo);
  1117. }
  1118. });
  1119. }
  1120. }
  1121. // 慢放
  1122. function clickPlaySlow() {
  1123. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  1124. szInfo = "";
  1125. if (oWndInfo != null) {
  1126. WebVideoCtrl.I_PlaySlow({
  1127. success: function () {
  1128. szInfo = "慢放成功!";
  1129. showOPInfo(oWndInfo.szDeviceIdentify + " " + szInfo);
  1130. },
  1131. error: function () {
  1132. szInfo = "慢放失败!";
  1133. showOPInfo(oWndInfo.szDeviceIdentify + " " + szInfo);
  1134. }
  1135. });
  1136. }
  1137. }
  1138. // 快放
  1139. function clickPlayFast() {
  1140. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  1141. szInfo = "";
  1142. if (oWndInfo != null) {
  1143. WebVideoCtrl.I_PlayFast({
  1144. success: function () {
  1145. szInfo = "快放成功!";
  1146. showOPInfo(oWndInfo.szDeviceIdentify + " " + szInfo);
  1147. },
  1148. error: function () {
  1149. szInfo = "快放失败!";
  1150. showOPInfo(oWndInfo.szDeviceIdentify + " " + szInfo);
  1151. }
  1152. });
  1153. }
  1154. }
  1155. // OSD时间
  1156. function clickGetOSDTime() {
  1157. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);
  1158. if (oWndInfo != null) {
  1159. var szTime = WebVideoCtrl.I_GetOSDTime({
  1160. success: function (szOSDTime) {
  1161. $("#osdtime").val(szOSDTime);
  1162. showOPInfo(oWndInfo.szDeviceIdentify + " 获取OSD时间成功!");
  1163. },
  1164. error: function () {
  1165. showOPInfo(oWndInfo.szDeviceIdentify + " 获取OSD时间失败!");
  1166. }
  1167. });
  1168. }
  1169. }
  1170. // 下载录像
  1171. var g_iDownloadID = -1;
  1172. var g_tDownloadProcess = 0;
  1173. function clickStartDownloadRecord(i) {
  1174. var szDeviceIdentify = $("#ip").val(),
  1175. szChannelID = $("#channels").val(),
  1176. szFileName = $("#downloadTd" + i).data("fileName"),
  1177. szPlaybackURI = $("#downloadTd" + i).data("playbackURI");
  1178. if (null == szDeviceIdentify) {
  1179. return;
  1180. }
  1181. g_iDownloadID = WebVideoCtrl.I_StartDownloadRecord(szDeviceIdentify, szPlaybackURI, szFileName, {
  1182. bDateDir: true //是否生成日期文件
  1183. });
  1184. if (g_iDownloadID < 0) {
  1185. var iErrorValue = WebVideoCtrl.I_GetLastError();
  1186. if (34 == iErrorValue) {
  1187. showOPInfo(szDeviceIdentify + " 已下载!");
  1188. } else if (33 == iErrorValue) {
  1189. showOPInfo(szDeviceIdentify + " 空间不足!");
  1190. } else {
  1191. showOPInfo(szDeviceIdentify + " 下载失败!");
  1192. }
  1193. } else {
  1194. $("<div id='downProcess' class='freeze'></div>").appendTo("body");
  1195. g_tDownloadProcess = setInterval("downProcess(" + i + ")", 1000);
  1196. }
  1197. }
  1198. function clickStartDownloadRecordByTime() {
  1199. var szDeviceIdentify = $("#ip").val(),
  1200. szChannelID = $("#channels").val(),
  1201. szFileName = $("#downloadTd0").data("fileName"),
  1202. szPlaybackURI = $("#downloadTd0").data("playbackURI"),
  1203. szStartTime = $("#downloadstarttime").val(),
  1204. szEndTime = $("#downloadendtime").val();
  1205. if (null == szDeviceIdentify) {
  1206. return;
  1207. }
  1208. if (Date.parse(szEndTime.replace(/-/g, "/")) - Date.parse(szStartTime.replace(/-/g, "/")) < 0) {
  1209. alert("开始时间大于结束时间");
  1210. return;
  1211. }
  1212. g_iDownloadID = WebVideoCtrl.I_StartDownloadRecordByTime(szDeviceIdentify, szPlaybackURI, szFileName, szStartTime,szEndTime,{
  1213. bDateDir: true //是否生成日期文件
  1214. });
  1215. if (g_iDownloadID < 0) {
  1216. var iErrorValue = WebVideoCtrl.I_GetLastError();
  1217. if (34 == iErrorValue) {
  1218. showOPInfo(szDeviceIdentify + " 已下载!");
  1219. } else if (33 == iErrorValue) {
  1220. showOPInfo(szDeviceIdentify + " 空间不足!");
  1221. } else {
  1222. showOPInfo(szDeviceIdentify + " 下载失败!");
  1223. }
  1224. } else {
  1225. $("<div id='downProcess' class='freeze'></div>").appendTo("body");
  1226. g_tDownloadProcess = setInterval("downProcess(" + 0 + ")", 1000);
  1227. }
  1228. }
  1229. // 下载进度
  1230. function downProcess() {
  1231. var iStatus = WebVideoCtrl.I_GetDownloadStatus(g_iDownloadID);
  1232. if (0 == iStatus) {
  1233. $("#downProcess").css({
  1234. width: $("#searchlist").width() + "px",
  1235. height: "100px",
  1236. lineHeight: "100px",
  1237. left: $("#searchdiv").offset().left + "px",
  1238. top: $("#searchdiv").offset().top + "px"
  1239. });
  1240. var iProcess = WebVideoCtrl.I_GetDownloadProgress(g_iDownloadID);
  1241. if (iProcess < 0) {
  1242. clearInterval(g_tDownloadProcess);
  1243. g_tDownloadProcess = 0;
  1244. g_iDownloadID = -1;
  1245. } else if (iProcess < 100) {
  1246. $("#downProcess").text(iProcess + "%");
  1247. } else {
  1248. $("#downProcess").text("100%");
  1249. setTimeout(function () {
  1250. $("#downProcess").remove();
  1251. }, 1000);
  1252. WebVideoCtrl.I_StopDownloadRecord(g_iDownloadID);
  1253. showOPInfo("录像下载完成!");
  1254. clearInterval(g_tDownloadProcess);
  1255. g_tDownloadProcess = 0;
  1256. g_iDownloadID = -1;
  1257. }
  1258. } else {
  1259. WebVideoCtrl.I_StopDownloadRecord(g_iDownloadID);
  1260. clearInterval(g_tDownloadProcess);
  1261. g_tDownloadProcess = 0;
  1262. g_iDownloadID = -1;
  1263. }
  1264. }
  1265. // 导出配置文件
  1266. function clickExportDeviceConfig() {
  1267. var szDeviceIdentify = $("#ip").val(),
  1268. szInfo = "";
  1269. if (null == szDeviceIdentify) {
  1270. return;
  1271. }
  1272. var szDevicePassWord = $("#edfpassword").val();
  1273. var iRet = WebVideoCtrl.I_ExportDeviceConfig(szDeviceIdentify,szDevicePassWord);
  1274. if (0 == iRet) {
  1275. szInfo = "导出配置文件成功!";
  1276. } else {
  1277. szInfo = "导出配置文件失败!";
  1278. }
  1279. showOPInfo(szDeviceIdentify + " " + szInfo);
  1280. }
  1281. // 导入配置文件
  1282. function clickImportDeviceConfig() {
  1283. var szDeviceIdentify = $("#ip").val(),
  1284. szFileName = $("#configFile").val(),
  1285. szDevicePassWord= $("#edfpassword").val();
  1286. if (null == szDeviceIdentify) {
  1287. return;
  1288. }
  1289. if ("" == szFileName) {
  1290. alert("请选择配置文件!");
  1291. return;
  1292. }
  1293. var iRet = WebVideoCtrl.I_ImportDeviceConfig(szDeviceIdentify, szFileName,szDevicePassWord);
  1294. if (0 == iRet) {
  1295. WebVideoCtrl.I_Restart(szDeviceIdentify, {
  1296. success: function (xmlDoc) {
  1297. $("<div id='restartDiv' class='freeze'>重启中...</div>").appendTo("body");
  1298. var oSize = getWindowSize();
  1299. $("#restartDiv").css({
  1300. width: oSize.width + "px",
  1301. height: oSize.height + "px",
  1302. lineHeight: oSize.height + "px",
  1303. left: 0,
  1304. top: 0
  1305. });
  1306. setTimeout("reconnect('" + szDeviceIdentify + "')", 20000);
  1307. },
  1308. error: function (status, xmlDoc) {
  1309. showOPInfo(szDeviceIdentify + " 重启失败!", status, xmlDoc);
  1310. }
  1311. });
  1312. } else {
  1313. showOPInfo(szDeviceIdentify + " 导入失败!");
  1314. }
  1315. }
  1316. // 重连
  1317. function reconnect(szDeviceIdentify) {
  1318. WebVideoCtrl.I_Reconnect(szDeviceIdentify, {
  1319. success: function (xmlDoc) {
  1320. $("#restartDiv").remove();
  1321. },
  1322. error: function (status, xmlDoc) {
  1323. if (401 == status) {// 无插件方案,重启后session已失效,程序执行登出,从已登录设备中删除
  1324. $("#restartDiv").remove();
  1325. clickLogout();
  1326. } else {
  1327. setTimeout(function () {reconnect(szDeviceIdentify);}, 5000);
  1328. }
  1329. }
  1330. });
  1331. }
  1332. // 开始升级
  1333. var g_tUpgrade = 0;
  1334. function clickStartUpgrade(szDeviceIdentify) {
  1335. var szDeviceIdentify = $("#ip").val(),
  1336. szFileName = $("#upgradeFile").val();
  1337. if (null == szDeviceIdentify) {
  1338. return;
  1339. }
  1340. if ("" == szFileName) {
  1341. alert("请选择升级文件!");
  1342. return;
  1343. }
  1344. WebVideoCtrl.I2_StartUpgrade(szDeviceIdentify, szFileName).then(function(){
  1345. g_tUpgrade = setInterval("getUpgradeStatus('" + szDeviceIdentify + "')", 1000);
  1346. },function(){
  1347. clearInterval(g_tUpgrade);
  1348. showOPInfo(szDeviceIdentify + " 升级失败!");
  1349. })
  1350. // var iRet = WebVideoCtrl.I2_StartUpgrade(szDeviceIdentify, szFileName);
  1351. }
  1352. // 获取升级状态
  1353. function getUpgradeStatus(szDeviceIdentify) {
  1354. var iStatus = WebVideoCtrl.I_UpgradeStatus();
  1355. if (iStatus == 0) {
  1356. var iProcess = WebVideoCtrl.I_UpgradeProgress();
  1357. if (iProcess < 0) {
  1358. clearInterval(g_tUpgrade);
  1359. g_tUpgrade = 0;
  1360. showOPInfo(szDeviceIdentify + " 获取进度失败!");
  1361. return;
  1362. } else if (iProcess < 100) {
  1363. if (0 == $("#restartDiv").length) {
  1364. $("<div id='restartDiv' class='freeze'></div>").appendTo("body");
  1365. var oSize = getWindowSize();
  1366. $("#restartDiv").css({
  1367. width: oSize.width + "px",
  1368. height: oSize.height + "px",
  1369. lineHeight: oSize.height + "px",
  1370. left: 0,
  1371. top: 0
  1372. });
  1373. }
  1374. $("#restartDiv").text(iProcess + "%");
  1375. } else {
  1376. WebVideoCtrl.I_StopUpgrade();
  1377. clearInterval(g_tUpgrade);
  1378. g_tUpgrade = 0;
  1379. $("#restartDiv").remove();
  1380. WebVideoCtrl.I_Restart(szDeviceIdentify, {
  1381. success: function (xmlDoc) {
  1382. $("<div id='restartDiv' class='freeze'>重启中...</div>").appendTo("body");
  1383. var oSize = getWindowSize();
  1384. $("#restartDiv").css({
  1385. width: oSize.width + "px",
  1386. height: oSize.height + "px",
  1387. lineHeight: oSize.height + "px",
  1388. left: 0,
  1389. top: 0
  1390. });
  1391. setTimeout("reconnect('" + szDeviceIdentify + "')", 20000);
  1392. },
  1393. error: function (status, xmlDoc) {
  1394. showOPInfo(szDeviceIdentify + " 重启失败!", status, xmlDoc);
  1395. }
  1396. });
  1397. }
  1398. } else if (iStatus == 1) {
  1399. WebVideoCtrl.I_StopUpgrade();
  1400. showOPInfo(szDeviceIdentify + " 升级失败!");
  1401. clearInterval(g_tUpgrade);
  1402. g_tUpgrade = 0;
  1403. } else if (iStatus == 2) {
  1404. mWebVideoCtrl.I_StopUpgrade();
  1405. showOPInfo(szDeviceIdentify + " 语言不匹配!");
  1406. clearInterval(g_tUpgrade);
  1407. g_tUpgrade = 0;
  1408. } else {
  1409. mWebVideoCtrl.I_StopUpgrade();
  1410. showOPInfo(szDeviceIdentify + " 获取状态失败!");
  1411. clearInterval(g_tUpgrade);
  1412. g_tUpgrade = 0;
  1413. }
  1414. }
  1415. // 检查插件版本
  1416. function clickCheckPluginVersion() {
  1417. var iRet = WebVideoCtrl.I_CheckPluginVersion();
  1418. if (0 == iRet) {
  1419. alert("您的插件版本已经是最新的!");
  1420. } else {
  1421. alert("检测到新的插件版本!");
  1422. }
  1423. }
  1424. // 远程配置库
  1425. function clickRemoteConfig() {
  1426. var szDeviceIdentify = $("#ip").val(),
  1427. iDevicePort = parseInt($("#deviceport").val(), 10) || "",
  1428. szInfo = "";
  1429. if (null == szDeviceIdentify) {
  1430. return;
  1431. }
  1432. var iRet = WebVideoCtrl.I_RemoteConfig(szDeviceIdentify, {
  1433. iDevicePort: iDevicePort,
  1434. iLan: 1
  1435. });
  1436. if (-1 == iRet) {
  1437. szInfo = "调用远程配置库失败!";
  1438. } else {
  1439. szInfo = "调用远程配置库成功!";
  1440. }
  1441. showOPInfo(szDeviceIdentify + " " + szInfo);
  1442. }
  1443. function clickRestoreDefault() {
  1444. var szDeviceIdentify = $("#ip").val(),
  1445. szMode = "basic";
  1446. WebVideoCtrl.I_RestoreDefault(szDeviceIdentify, szMode, {
  1447. timeout: 30000,
  1448. success: function (xmlDoc) {
  1449. $("#restartDiv").remove();
  1450. showOPInfo(szDeviceIdentify + " 恢复默认参数成功!");
  1451. //恢复完成后需要重启
  1452. WebVideoCtrl.I_Restart(szDeviceIdentify, {
  1453. success: function (xmlDoc) {
  1454. $("<div id='restartDiv' class='freeze'>重启中...</div>").appendTo("body");
  1455. var oSize = getWindowSize();
  1456. $("#restartDiv").css({
  1457. width: oSize.width + "px",
  1458. height: oSize.height + "px",
  1459. lineHeight: oSize.height + "px",
  1460. left: 0,
  1461. top: 0
  1462. });
  1463. setTimeout("reconnect('" + szDeviceIdentify + "')", 20000);
  1464. },
  1465. error: function (status, xmlDoc) {
  1466. showOPInfo(szDeviceIdentify + " 重启失败!", status, xmlDoc);
  1467. }
  1468. });
  1469. },
  1470. error: function (status, xmlDoc) {
  1471. showOPInfo(szDeviceIdentify + " 恢复默认参数失败!", status, xmlDoc);
  1472. }
  1473. });
  1474. }
  1475. function PTZZoomIn() {
  1476. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);
  1477. if (oWndInfo != null) {
  1478. WebVideoCtrl.I_PTZControl(10, false, {
  1479. iWndIndex: g_iWndIndex,
  1480. success: function (xmlDoc) {
  1481. showOPInfo(oWndInfo.szDeviceIdentify + " 调焦+成功!");
  1482. },
  1483. error: function (status, xmlDoc) {
  1484. showOPInfo(oWndInfo.szDeviceIdentify + " 调焦+失败!", status, xmlDoc);
  1485. }
  1486. });
  1487. }
  1488. }
  1489. function PTZZoomout() {
  1490. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);
  1491. if (oWndInfo != null) {
  1492. WebVideoCtrl.I_PTZControl(11, false, {
  1493. iWndIndex: g_iWndIndex,
  1494. success: function (xmlDoc) {
  1495. showOPInfo(oWndInfo.szDeviceIdentify + " 调焦-成功!");
  1496. },
  1497. error: function (status, xmlDoc) {
  1498. showOPInfo(oWndInfo.szDeviceIdentify + " 调焦-失败!", status, xmlDoc);
  1499. }
  1500. });
  1501. }
  1502. }
  1503. function PTZZoomStop() {
  1504. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);
  1505. if (oWndInfo != null) {
  1506. WebVideoCtrl.I_PTZControl(11, true, {
  1507. iWndIndex: g_iWndIndex,
  1508. success: function (xmlDoc) {
  1509. showOPInfo(oWndInfo.szDeviceIdentify + " 调焦停止成功!");
  1510. },
  1511. error: function (status, xmlDoc) {
  1512. showOPInfo(oWndInfo.szDeviceIdentify + " 调焦停止失败!", status, xmlDoc);
  1513. }
  1514. });
  1515. }
  1516. }
  1517. function PTZFocusIn() {
  1518. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);
  1519. if (oWndInfo != null) {
  1520. WebVideoCtrl.I_PTZControl(12, false, {
  1521. iWndIndex: g_iWndIndex,
  1522. success: function (xmlDoc) {
  1523. showOPInfo(oWndInfo.szDeviceIdentify + " 聚焦+成功!");
  1524. },
  1525. error: function (status, xmlDoc) {
  1526. showOPInfo(oWndInfo.szDeviceIdentify + " 聚焦+失败!", status, xmlDoc);
  1527. }
  1528. });
  1529. }
  1530. }
  1531. function PTZFoucusOut() {
  1532. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);
  1533. if (oWndInfo != null) {
  1534. WebVideoCtrl.I_PTZControl(13, false, {
  1535. iWndIndex: g_iWndIndex,
  1536. success: function (xmlDoc) {
  1537. showOPInfo(oWndInfo.szDeviceIdentify + " 聚焦-成功!");
  1538. },
  1539. error: function (status, xmlDoc) {
  1540. showOPInfo(oWndInfo.szDeviceIdentify + " 聚焦-失败!", status, xmlDoc);
  1541. }
  1542. });
  1543. }
  1544. }
  1545. function PTZFoucusStop() {
  1546. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);
  1547. if (oWndInfo != null) {
  1548. WebVideoCtrl.I_PTZControl(12, true, {
  1549. iWndIndex: g_iWndIndex,
  1550. success: function (xmlDoc) {
  1551. showOPInfo(oWndInfo.szDeviceIdentify + " 聚焦停止成功!");
  1552. },
  1553. error: function (status, xmlDoc) {
  1554. showOPInfo(oWndInfo.szDeviceIdentify + " 聚焦停止失败!", status, xmlDoc);
  1555. }
  1556. });
  1557. }
  1558. }
  1559. function PTZIrisIn() {
  1560. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);
  1561. if (oWndInfo != null) {
  1562. WebVideoCtrl.I_PTZControl(14, false, {
  1563. iWndIndex: g_iWndIndex,
  1564. success: function (xmlDoc) {
  1565. showOPInfo(oWndInfo.szDeviceIdentify + " 光圈+成功!");
  1566. },
  1567. error: function (status, xmlDoc) {
  1568. showOPInfo(oWndInfo.szDeviceIdentify + " 光圈+失败!", status, xmlDoc);
  1569. }
  1570. });
  1571. }
  1572. }
  1573. function PTZIrisOut() {
  1574. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);
  1575. if (oWndInfo != null) {
  1576. WebVideoCtrl.I_PTZControl(15, false, {
  1577. iWndIndex: g_iWndIndex,
  1578. success: function (xmlDoc) {
  1579. showOPInfo(oWndInfo.szDeviceIdentify + " 光圈-成功!");
  1580. },
  1581. error: function (status, xmlDoc) {
  1582. showOPInfo(oWndInfo.szDeviceIdentify + " 光圈-失败!", status, xmlDoc);
  1583. }
  1584. });
  1585. }
  1586. }
  1587. function PTZIrisStop() {
  1588. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);
  1589. if (oWndInfo != null) {
  1590. WebVideoCtrl.I_PTZControl(14, true, {
  1591. iWndIndex: g_iWndIndex,
  1592. success: function (xmlDoc) {
  1593. showOPInfo(oWndInfo.szDeviceIdentify + " 光圈停止成功!");
  1594. },
  1595. error: function (status, xmlDoc) {
  1596. showOPInfo(oWndInfo.szDeviceIdentify + " 光圈停止失败!", status, xmlDoc);
  1597. }
  1598. });
  1599. }
  1600. }
  1601. // 切换模式
  1602. function changeIPMode(iType) {
  1603. var arrPort = [0, 7071, 80];
  1604. $("#serverport").val(arrPort[iType]);
  1605. }
  1606. // 获取设备IP
  1607. function clickGetDeviceIP() {
  1608. var iDeviceMode = parseInt($("#devicemode").val(), 10),
  1609. szAddress = $("#serveraddress").val(),
  1610. iPort = parseInt($("#serverport").val(), 10) || 0,
  1611. szDeviceID = $("#deviceid").val(),
  1612. szDeviceInfo = "";
  1613. szDeviceInfo = WebVideoCtrl.I_GetIPInfoByMode(iDeviceMode, szAddress, iPort, szDeviceID);
  1614. if ("" == szDeviceInfo) {
  1615. showOPInfo("设备IP和端口解析失败!");
  1616. } else {
  1617. showOPInfo("设备IP和端口解析成功!");
  1618. var arrTemp = szDeviceInfo.split("-");
  1619. $("#loginip").val(arrTemp[0]);
  1620. $("#deviceport").val(arrTemp[1]);
  1621. }
  1622. }
  1623. // 启用多边形绘制
  1624. var g_bEnableDraw = false;
  1625. function clickEnableDraw() {
  1626. var iRet = WebVideoCtrl.I_SetPlayModeType(6);// 多边形模式
  1627. if (0 === iRet) {
  1628. g_bEnableDraw = true;
  1629. showOPInfo("启用绘制成功!");
  1630. } else {
  1631. showOPInfo("启用绘制失败!");
  1632. }
  1633. }
  1634. // 禁用多边形绘制
  1635. function clickDisableDraw() {
  1636. var iRet = WebVideoCtrl.I_SetPlayModeType(0);// 预览模式
  1637. if (0 === iRet) {
  1638. g_bEnableDraw = false;
  1639. showOPInfo("禁用绘制成功!");
  1640. } else {
  1641. showOPInfo("禁用绘制失败!");
  1642. }
  1643. }
  1644. // 添加图形
  1645. function clickAddSnapPolygon() {
  1646. if (!g_bEnableDraw) {
  1647. return;
  1648. }
  1649. var szId = $("#snapId").val();
  1650. var szName = encodeString($("#snapName").val());
  1651. var szInfo = "<?xml version='1.0' encoding='utf-8'?>";
  1652. szInfo += "<SnapPolygonList>";
  1653. szInfo += "<SnapPolygon>";
  1654. szInfo += "<id>" + szId + "</id>"; // [1, 32]
  1655. szInfo += "<polygonType>1</polygonType>";
  1656. szInfo += "<PointNumMax>17</PointNumMax>"; // [MinClosed, 17]
  1657. szInfo += "<MinClosed>4</MinClosed>"; // [4, 17]
  1658. szInfo += "<tips>#" + szId + "#" + szName + "</tips>";
  1659. szInfo += "<isClosed>false</isClosed>";
  1660. szInfo += "<color><r>0</r><g>255</g><b>0</b></color>";
  1661. szInfo += "<pointList/>";
  1662. szInfo += "</SnapPolygon>";
  1663. szInfo += "</SnapPolygonList>";
  1664. var iRet = WebVideoCtrl.I_SetSnapPolygonInfo(g_iWndIndex, szInfo);
  1665. if (0 === iRet) {
  1666. showOPInfo("窗口" + g_iWndIndex + "添加图形成功!");
  1667. } else if (-1 === iRet) {
  1668. showOPInfo("窗口" + g_iWndIndex + "添加图形失败!");
  1669. } else if (-2 === iRet) {
  1670. alert("参数错误!");
  1671. } else if (-3 === iRet) {
  1672. alert("图形个数达到上限!");
  1673. } else if (-4 === iRet) {
  1674. alert("图形ID已存在!");
  1675. }
  1676. WebVideoCtrl.I_SetSnapDrawMode(g_iWndIndex, 2);
  1677. }
  1678. // 删除图形
  1679. function clickDelSnapPolygon() {
  1680. if (!g_bEnableDraw) {
  1681. return;
  1682. }
  1683. var szId = $("#snapId").val();
  1684. var iIndex = getSnapPolygon(szId);
  1685. if (iIndex != -1) {
  1686. var oXML = getSnapPolygon();
  1687. $(oXML).find("SnapPolygon").eq(iIndex).remove();
  1688. var szInfo = toXMLStr(oXML);
  1689. WebVideoCtrl.I_ClearSnapInfo(g_iWndIndex);
  1690. WebVideoCtrl.I2_SetSnapPolygonInfo(g_iWndIndex, szInfo);
  1691. WebVideoCtrl.I_SetSnapDrawMode(g_iWndIndex, 3);
  1692. } else {
  1693. alert("图形ID不存在!");
  1694. }
  1695. }
  1696. // 编辑图形
  1697. function clickEditSnapPolygon() {
  1698. if (!g_bEnableDraw) {
  1699. return;
  1700. }
  1701. var iRet = WebVideoCtrl.I_SetSnapDrawMode(g_iWndIndex, 3);
  1702. if (0 === iRet) {
  1703. showOPInfo("窗口" + g_iWndIndex + "编辑图形成功!");
  1704. } else {
  1705. showOPInfo("窗口" + g_iWndIndex + "编辑图形失败!");
  1706. }
  1707. }
  1708. // 停止编辑
  1709. function clickStopSnapPolygon() {
  1710. if (!g_bEnableDraw) {
  1711. return;
  1712. }
  1713. var iRet = WebVideoCtrl.I_SetSnapDrawMode(g_iWndIndex, -1);
  1714. if (0 === iRet) {
  1715. showOPInfo("窗口" + g_iWndIndex + "停止编辑成功!");
  1716. } else {
  1717. showOPInfo("窗口" + g_iWndIndex + "停止编辑失败!");
  1718. }
  1719. }
  1720. function getSnapPolygon(szId) {
  1721. var szInfo = WebVideoCtrl.I_GetSnapPolygonInfo(g_iWndIndex);
  1722. var oXML = loadXML(szInfo);
  1723. if (typeof szId === "undefined") {
  1724. return oXML;
  1725. } else {
  1726. var iIndex = -1;
  1727. var aNodeList = $(oXML).find("SnapPolygon");
  1728. if (aNodeList.length > 0) {
  1729. $.each(aNodeList, function (i) {
  1730. if ($(this).find("id").text() === szId) {
  1731. iIndex = i;
  1732. return false;
  1733. }
  1734. });
  1735. }
  1736. return iIndex;
  1737. }
  1738. }
  1739. // 获取图形,保存到自己数据库中
  1740. function clickGetSnapPolygon() {
  1741. if (!g_bEnableDraw) {
  1742. return;
  1743. }
  1744. var szInfo = WebVideoCtrl.I_GetSnapPolygonInfo(g_iWndIndex);
  1745. alert(szInfo);
  1746. }
  1747. // 设置图形,页面打开时可以设置以前设置过的图形
  1748. function clickSetSnapPolygon() {
  1749. if (!g_bEnableDraw) {
  1750. return;
  1751. }
  1752. WebVideoCtrl.I_ClearSnapInfo(g_iWndIndex);
  1753. var szInfo = "<?xml version='1.0' encoding='utf-8'?>";
  1754. szInfo += "<SnapPolygonList>";
  1755. szInfo += "<SnapPolygon>";
  1756. szInfo += "<id>1</id>";
  1757. szInfo += "<polygonType>1</polygonType>";
  1758. szInfo += "<tips>#1#设置1</tips>";
  1759. szInfo += "<isClosed>true</isClosed>";
  1760. szInfo += "<color><r>0</r><g>255</g><b>0</b></color>";
  1761. szInfo += "<pointList>";
  1762. szInfo += "<point><x>0.737903</x><y>0.229730</y></point>";
  1763. szInfo += "<point><x>0.947581</x><y>0.804054</y></point>";
  1764. szInfo += "<point><x>0.362903</x><y>0.777027</y></point>";
  1765. szInfo += "</pointList>";
  1766. szInfo += "</SnapPolygon>";
  1767. szInfo += "<SnapPolygon>";
  1768. szInfo += "<id>2</id>";
  1769. szInfo += "<polygonType>1</polygonType>";
  1770. szInfo += "<tips>#2#设置2</tips>";
  1771. szInfo += "<isClosed>true</isClosed>";
  1772. szInfo += "<color><r>0</r><g>255</g><b>0</b></color>";
  1773. szInfo += "<pointList>";
  1774. szInfo += "<point><x>0.451613</x><y>0.216216</y></point>";
  1775. szInfo += "<point><x>0.447581</x><y>0.729730</y></point>";
  1776. szInfo += "<point><x>0.116935</x><y>0.554054</y></point>";
  1777. szInfo += "</pointList>";
  1778. szInfo += "</SnapPolygon>";
  1779. szInfo += "</SnapPolygonList>";
  1780. var iRet = WebVideoCtrl.I2_SetSnapPolygonInfo(g_iWndIndex, szInfo);
  1781. if (0 === iRet) {
  1782. showOPInfo("窗口" + g_iWndIndex + "设置图形成功!");
  1783. } else if (-1 === iRet) {
  1784. showOPInfo("窗口" + g_iWndIndex + "设置图形失败!");
  1785. } else if (-2 === iRet) {
  1786. alert("参数错误!");
  1787. } else if (-3 === iRet) {
  1788. alert("图形个数达到上限!");
  1789. } else if (-4 === iRet) {
  1790. alert("图形ID已存在!");
  1791. }
  1792. }
  1793. // 清空图形
  1794. function clickDelAllSnapPolygon() {
  1795. if (!g_bEnableDraw) {
  1796. return;
  1797. }
  1798. var iRet = WebVideoCtrl.I_ClearSnapInfo(g_iWndIndex);
  1799. if (0 === iRet) {
  1800. showOPInfo("窗口" + g_iWndIndex + "清空图形成功!");
  1801. } else {
  1802. showOPInfo("窗口" + g_iWndIndex + "清空图形失败!");
  1803. }
  1804. }
  1805. // 设备抓图
  1806. function clickDeviceCapturePic() {
  1807. var szInfo = "";
  1808. var szDeviceIdentify = $("#ip").val();
  1809. var bZeroChannel = $("#channels option").eq($("#channels").get(0).selectedIndex).attr("bZero") == "true" ? true : false;
  1810. var iChannelID = parseInt($("#channels").val(), 10);
  1811. var iResolutionWidth = parseInt($("#resolutionWidth").val(), 10);
  1812. var iResolutionHeight = parseInt($("#resolutionHeight").val(), 10);
  1813. if (null == szDeviceIdentify) {
  1814. return;
  1815. }
  1816. if (bZeroChannel) {// 零通道不支持设备抓图
  1817. return;
  1818. }
  1819. var szPicName = szDeviceIdentify + "_" + iChannelID + "_" + new Date().getTime();
  1820. var iRet = WebVideoCtrl.I_DeviceCapturePic(szDeviceIdentify, iChannelID, szPicName, {
  1821. bDateDir: true, //是否生成日期文件
  1822. iResolutionWidth: iResolutionWidth,
  1823. iResolutionHeight: iResolutionHeight
  1824. });
  1825. if (0 == iRet) {
  1826. szInfo = "设备抓图成功!";
  1827. } else {
  1828. szInfo = "设备抓图失败!";
  1829. }
  1830. showOPInfo(szDeviceIdentify + " " + szInfo);
  1831. }
  1832. function loadXML(szXml) {
  1833. if(null == szXml || "" == szXml) {
  1834. return null;
  1835. }
  1836. var oXmlDoc = null;
  1837. if (window.DOMParser) {
  1838. var oParser = new DOMParser();
  1839. oXmlDoc = oParser.parseFromString(szXml, "text/xml");
  1840. } else {
  1841. oXmlDoc = new ActiveXObject("Microsoft.XMLDOM");
  1842. oXmlDoc.async = false;
  1843. oXmlDoc.loadXML(szXml);
  1844. }
  1845. return oXmlDoc;
  1846. }
  1847. function toXMLStr(oXmlDoc) {
  1848. var szXmlDoc = "";
  1849. try {
  1850. var oSerializer = new XMLSerializer();
  1851. szXmlDoc = oSerializer.serializeToString(oXmlDoc);
  1852. } catch (e) {
  1853. try {
  1854. szXmlDoc = oXmlDoc.xml;
  1855. } catch (e) {
  1856. return "";
  1857. }
  1858. }
  1859. if (szXmlDoc.indexOf("<?xml") == -1) {
  1860. szXmlDoc = "<?xml version='1.0' encoding='utf-8'?>" + szXmlDoc;
  1861. }
  1862. return szXmlDoc;
  1863. }
  1864. function encodeString(str) {
  1865. if (str) {
  1866. return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
  1867. } else {
  1868. return "";
  1869. }
  1870. }