├── README.md ├── WebApi.pdf ├── WebComponents.exe ├── example-cn ├── demo.css ├── demo.html ├── demo.js ├── jquery-1.7.1.min.js └── webVideoCtrl.js ├── example-en ├── demo.css ├── demo.html ├── demo.js ├── jquery-1.7.1.min.js └── webVideoCtrl.js └── example-loopplay ├── index.html ├── index.js ├── jquery-1.7.1.min.js ├── list.js ├── map.js └── webVideoCtrl.js /README.md: -------------------------------------------------------------------------------- 1 | # hikvision-web 2 | 海康威视网络摄像机的IE Web页面操作demo,其中包括网络摄像机的账户登录、平台登陆、图像实时预览、云台的控制、视频抓图、录像回放、回放截图、配置文件升级设备等操作。 3 | 4 | ## 使用方式 5 | - 下载项目 6 | - 安装运行 WebComponents.exe 插件,插件仅仅支持 IE 浏览器 7 | - 直接运行 example 文件夹中的 html 文件即可 8 | 9 | ## 说明 10 | - webVideoCtrl.js 为 js api 文件,操作网络摄像机引入该 js 文件即可 11 | - WebApi.pdf 为 js api的操作说明 12 | - example-cn 文件夹中为完整的功能 demo,采用中文 13 | - example-en 文件夹中为完整的功能 demo,采用英文 14 | - example-loopplay 文件夹中为几批摄像头轮训播放 demo,在一定时间内切换一组摄像头进行播放 15 | -------------------------------------------------------------------------------- /WebApi.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igoer/hikvision-web/072518067b1d4b629e459532f05940c31c2ded04/WebApi.pdf -------------------------------------------------------------------------------- /WebComponents.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igoer/hikvision-web/072518067b1d4b629e459532f05940c31c2ded04/WebComponents.exe -------------------------------------------------------------------------------- /example-cn/demo.css: -------------------------------------------------------------------------------- 1 | @charset "utf-8"; 2 | * 3 | { 4 | margin:0; 5 | padding:0; 6 | } 7 | html 8 | { 9 | width:100%; 10 | height:100%; 11 | font-size:12px; 12 | font-family:Arial, Helvetica, sans-serif; 13 | -webkit-text-size-adjust:none; 14 | background:#FFFFFF; 15 | } 16 | body 17 | { 18 | padding:5px; 19 | } 20 | select 21 | { 22 | height:20px; 23 | line-height:20px; 24 | } 25 | .left 26 | { 27 | float:left; 28 | } 29 | .freeze 30 | { 31 | position:absolute; 32 | text-align:center; 33 | background:#343434; 34 | color:#FFFFFF; 35 | font-size:26px; 36 | font-weight:bold; 37 | filter:alpha(opacity=60); 38 | opacity:0.6; 39 | } 40 | .vtop 41 | { 42 | vertical-align:middle; 43 | margin-top:-1px; 44 | } 45 | /*插件*/ 46 | .plugin 47 | { 48 | width:500px; 49 | height:300px; 50 | } 51 | fieldset 52 | { 53 | display:block; 54 | } 55 | /*本地配置*/ 56 | .localconfig 57 | { 58 | width:480px; 59 | padding:10px; 60 | border:1px solid #7F9DB9; 61 | } 62 | .localconfig .tt 63 | { 64 | width:125px; 65 | } 66 | .localconfig .txt 67 | { 68 | width:310px; 69 | } 70 | .localconfig .btn 71 | { 72 | width:45px; 73 | height:22px; 74 | line-height:18px; 75 | } 76 | .localconfig .sel 77 | { 78 | width:120px; 79 | } 80 | /*登录*/ 81 | .login 82 | { 83 | width:480px; 84 | padding:10px; 85 | border:1px solid #7F9DB9; 86 | } 87 | .login .tt 88 | { 89 | width:100px; 90 | } 91 | .login .txt 92 | { 93 | width:130px; 94 | } 95 | .login .btn 96 | { 97 | width:45px; 98 | height:22px; 99 | line-height:18px; 100 | } 101 | .login .btn2 102 | { 103 | width:100px; 104 | height:22px; 105 | line-height:18px; 106 | } 107 | .login .sel 108 | { 109 | width:130px; 110 | } 111 | .login .sel2 112 | { 113 | width:65px; 114 | } 115 | /*数字通道*/ 116 | .ipchannel 117 | { 118 | width:480px; 119 | padding:10px; 120 | border:1px solid #7F9DB9; 121 | } 122 | .ipchannel .btn 123 | { 124 | width:130px; 125 | height:22px; 126 | line-height:18px; 127 | } 128 | .ipchannel .digitaltdiv 129 | { 130 | height:100px; 131 | overflow:hidden; 132 | overflow-y:auto; 133 | border:1px solid #7F9DB9; 134 | font-size:11px; 135 | } 136 | .ipchannel .digitalchannellist th, .ipchannel .digitalchannellist td 137 | { 138 | padding:2px; 139 | border:1px solid #7F9DB9; 140 | border-collapse:collapse; 141 | white-space:nowrap; 142 | } 143 | /*预览*/ 144 | .preview 145 | { 146 | width:450px; 147 | padding:10px; 148 | padding-top:0; 149 | margin-left:10px; 150 | border:1px solid #7F9DB9; 151 | } 152 | .preview .tt 153 | { 154 | width:60px; 155 | } 156 | .preview .txt 157 | { 158 | width:30px; 159 | } 160 | .preview .btn 161 | { 162 | width:70px; 163 | height:22px; 164 | line-height:18px; 165 | } 166 | .preview .btn2 167 | { 168 | width:90px; 169 | height:22px; 170 | line-height:18px; 171 | } 172 | .preview .sel 173 | { 174 | width:105px; 175 | } 176 | /*云台*/ 177 | .ptz 178 | { 179 | width:450px; 180 | padding:10px; 181 | margin-left:10px; 182 | border:1px solid #7F9DB9; 183 | } 184 | .ptz .tt 185 | { 186 | width:60px; 187 | } 188 | .ptz .txt 189 | { 190 | width:60px; 191 | } 192 | .ptz .btn 193 | { 194 | width:45px; 195 | height:22px; 196 | line-height:18px; 197 | } 198 | .ptz .btn2 199 | { 200 | width:60px; 201 | height:22px; 202 | line-height:18px; 203 | } 204 | .ptz .sel 205 | { 206 | width:65px; 207 | } 208 | /*视频参数*/ 209 | .videoparam 210 | { 211 | width:450px; 212 | padding:10px; 213 | margin-left:10px; 214 | border:1px solid #7F9DB9; 215 | } 216 | .videoparam .tt 217 | { 218 | width:60px; 219 | } 220 | .videoparam .txt 221 | { 222 | width:60px; 223 | } 224 | .videoparam .btn 225 | { 226 | width:45px; 227 | height:22px; 228 | line-height:18px; 229 | } 230 | .videoparam .sel 231 | { 232 | width:65px; 233 | } 234 | /*回放*/ 235 | .playback 236 | { 237 | width:450px; 238 | padding:10px; 239 | margin-left:10px; 240 | border:1px solid #7F9DB9; 241 | } 242 | .playback .tt 243 | { 244 | width:60px; 245 | } 246 | .playback .txt 247 | { 248 | width:140px; 249 | } 250 | .playback .btn 251 | { 252 | width:45px; 253 | height:22px; 254 | line-height:18px; 255 | } 256 | .playback .btn2 257 | { 258 | width:70px; 259 | height:22px; 260 | line-height:18px; 261 | } 262 | .playback .sel 263 | { 264 | width:65px; 265 | } 266 | .playback .searchdiv 267 | { 268 | height:100px; 269 | overflow:hidden; 270 | overflow-y:auto; 271 | border:1px solid #7F9DB9; 272 | font-size:11px; 273 | } 274 | .playback .searchlist th, .playback .searchlist td 275 | { 276 | padding:2px; 277 | border:1px solid #7F9DB9; 278 | border-collapse:collapse; 279 | white-space:nowrap; 280 | } 281 | /*系统维护*/ 282 | .maintain 283 | { 284 | width:450px; 285 | padding:10px; 286 | margin-left:10px; 287 | border:1px solid #7F9DB9; 288 | } 289 | .maintain .tt 290 | { 291 | width:60px; 292 | } 293 | .maintain .txt 294 | { 295 | width:280px; 296 | } 297 | .maintain .btn 298 | { 299 | width:45px; 300 | height:22px; 301 | line-height:18px; 302 | } 303 | .maintain .btn2 304 | { 305 | width:100px; 306 | height:22px; 307 | line-height:18px; 308 | } 309 | .maintain .sel 310 | { 311 | width:65px; 312 | } 313 | /*操作信息*/ 314 | .operate 315 | { 316 | width:450px; 317 | padding:10px; 318 | margin-left:10px; 319 | border:1px solid #7F9DB9; 320 | } 321 | .operate .opinfo 322 | { 323 | height:150px; 324 | border:1px solid #7F9DB9; 325 | overflow:auto; 326 | } 327 | /*事件回调*/ 328 | .callback 329 | { 330 | width:450px; 331 | padding:10px; 332 | margin-left:10px; 333 | border:1px solid #7F9DB9; 334 | } 335 | .callback .cbinfo 336 | { 337 | height:114px; 338 | border:1px solid #7F9DB9; 339 | overflow:auto; 340 | } 341 | /*IP解析*/ 342 | .ipparse 343 | { 344 | width:480px; 345 | padding:10px; 346 | border:1px solid #7F9DB9; 347 | } 348 | .ipparse .tt 349 | { 350 | width:100px; 351 | } 352 | .ipparse .txt 353 | { 354 | width:130px; 355 | } 356 | .ipparse .btn 357 | { 358 | width:90px; 359 | height:22px; 360 | line-height:18px; 361 | } 362 | .ipparse .sel 363 | { 364 | width:130px; 365 | } -------------------------------------------------------------------------------- /example-cn/demo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 14 |
15 |
16 |
17 | 设备IP解析 18 | 19 | 20 | 21 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 |
模式 22 | 26 |
服务器地址端口号
设备标识 
41 |
42 |
43 | 登录 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 69 | 70 | 71 | 76 | 77 | 78 | 79 | 82 | 83 | 86 | 87 |
IP地址端口号
用户名密码
设备端口(可选参数) 61 | 窗口分割数  62 | 68 |
72 | 73 | 74 | 75 |
已登录设备 80 | 81 | 通道列表 84 | 85 |
88 |
89 |
90 | 数字通道 91 | 92 | 93 | 94 | 95 | 96 | 101 | 102 |
97 |
98 |
99 |
100 |
103 |
104 |
105 | 本地配置 106 | 107 | 108 | 109 | 117 | 118 | 125 | 126 | 127 | 128 | 134 | 135 | 141 | 142 | 143 | 144 | 151 | 152 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 |
播放性能 110 | 116 | 图像尺寸 119 | 124 |
规则信息 129 | 133 | 抓图文件格式 136 | 140 |
录像文件打包大小 145 | 150 | 协议类型 153 | 157 |
录像文件保存路径 
回放下载保存路径 
预览抓图保存路径 
回放抓图保存路径 
回放剪辑保存路径 
 
183 |
184 |
185 |
186 |
187 | 预览 188 | 189 | 190 | 191 | 199 | 203 | 204 | 205 | 206 | 209 | 213 | 214 | 215 | 216 | 222 | 226 | 227 | 228 | 233 | 234 | 235 | 242 | 243 |
码流类型 192 | 198 | 200 | 201 | 202 |
音量 207 |  (范围:0~100) 208 | 210 | 211 | 212 |
对讲通道 217 | 220 | 221 | 223 | 224 | 225 |
229 | 230 | 231 | 232 |
236 | 237 | 238 | 239 | 240 | 241 |
244 |
245 |
246 | 云台控制 247 | 248 | 249 | 254 | 255 | 256 | 261 | 262 | 263 | 268 | 269 |
250 | 251 | 252 | 253 |
257 | 258 | 259 | 260 |
264 | 265 | 266 | 267 |
270 | 271 | 272 | 273 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 294 | 295 |
云台速度 274 | 283 |
预置点号
291 | 292 | 293 |
296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 |
310 |
311 |
312 | 回放 313 | 314 | 315 | 316 | 319 | 320 | 321 | 322 | 326 | 327 | 328 | 333 | 334 | 335 | 342 | 343 | 344 | 350 | 351 | 352 | 358 | 359 |
开始时间 317 | (时间格式:2013-11-11 12:34:56) 318 |
结束时间 323 | 324 | 325 |
329 |
330 |
331 |
332 |
336 | 337 | 338 | 339 | 340 |  启用转码码流 341 |
345 | 346 | 347 | 348 | 349 |
353 | 354 | 355 | 356 |   357 |
360 |
361 |
362 | 系统维护 363 | 364 | 365 | 371 | 372 | 373 | 376 | 377 | 378 | 381 | 382 |
366 | 367 | 368 | 369 | 370 |
374 |    375 |
379 |    380 |
383 |
384 |
385 | 操作信息 386 |
387 |
388 |
389 | 事件回调信息 390 |
391 |
392 |
393 | 394 | 395 | 396 | 397 | 398 | -------------------------------------------------------------------------------- /example-cn/demo.js: -------------------------------------------------------------------------------- 1 | // 初始化插件 2 | 3 | // 全局保存当前选中窗口 4 | var g_iWndIndex = 0; //可以不用设置这个变量,有窗口参数的接口中,不用传值,开发包会默认使用当前选择窗口 5 | $(function () { 6 | // 检查插件是否已经安装过 7 | if (-1 == WebVideoCtrl.I_CheckPluginInstall()) { 8 | alert("您还未安装过插件,双击开发包目录里的WebComponents.exe安装!"); 9 | return; 10 | } 11 | 12 | // 初始化插件参数及插入插件 13 | WebVideoCtrl.I_InitPlugin(500, 300, { 14 | iWndowType: 2, 15 | cbSelWnd: function (xmlDoc) { 16 | g_iWndIndex = $(xmlDoc).find("SelectWnd").eq(0).text(); 17 | var szInfo = "当前选择的窗口编号:" + g_iWndIndex; 18 | showCBInfo(szInfo); 19 | } 20 | }); 21 | WebVideoCtrl.I_InsertOBJECTPlugin("divPlugin"); 22 | 23 | // 检查插件是否最新 24 | if (-1 == WebVideoCtrl.I_CheckPluginVersion()) { 25 | alert("检测到新的插件版本,双击开发包目录里的WebComponents.exe升级!"); 26 | return; 27 | } 28 | 29 | // 窗口事件绑定 30 | $(window).bind({ 31 | resize: function () { 32 | var $Restart = $("#restartDiv"); 33 | if ($Restart.length > 0) { 34 | var oSize = getWindowSize(); 35 | $Restart.css({ 36 | width: oSize.width + "px", 37 | height: oSize.height + "px" 38 | }); 39 | } 40 | } 41 | }); 42 | 43 | //初始化日期时间 44 | var szCurTime = dateFormat(new Date(), "yyyy-MM-dd"); 45 | $("#starttime").val(szCurTime + " 00:00:00"); 46 | $("#endtime").val(szCurTime + " 23:59:59"); 47 | }); 48 | 49 | // 显示操作信息 50 | function showOPInfo(szInfo) { 51 | szInfo = "
" + dateFormat(new Date(), "yyyy-MM-dd hh:mm:ss") + " " + szInfo + "
"; 52 | $("#opinfo").html(szInfo + $("#opinfo").html()); 53 | } 54 | 55 | // 显示回调信息 56 | function showCBInfo(szInfo) { 57 | szInfo = "
" + dateFormat(new Date(), "yyyy-MM-dd hh:mm:ss") + " " + szInfo + "
"; 58 | $("#cbinfo").html(szInfo + $("#cbinfo").html()); 59 | } 60 | 61 | // 格式化时间 62 | function dateFormat(oDate, fmt) { 63 | var o = { 64 | "M+": oDate.getMonth() + 1, //月份 65 | "d+": oDate.getDate(), //日 66 | "h+": oDate.getHours(), //小时 67 | "m+": oDate.getMinutes(), //分 68 | "s+": oDate.getSeconds(), //秒 69 | "q+": Math.floor((oDate.getMonth() + 3) / 3), //季度 70 | "S": oDate.getMilliseconds()//毫秒 71 | }; 72 | if (/(y+)/.test(fmt)) { 73 | fmt = fmt.replace(RegExp.$1, (oDate.getFullYear() + "").substr(4 - RegExp.$1.length)); 74 | } 75 | for (var k in o) { 76 | if (new RegExp("(" + k + ")").test(fmt)) { 77 | fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); 78 | } 79 | } 80 | return fmt; 81 | } 82 | 83 | // 获取窗口尺寸 84 | function getWindowSize() { 85 | var nWidth = $(this).width() + $(this).scrollLeft(), 86 | nHeight = $(this).height() + $(this).scrollTop(); 87 | 88 | return {width: nWidth, height: nHeight}; 89 | } 90 | 91 | // 打开选择框 0:文件夹 1:文件 92 | function clickOpenFileDlg(id, iType) { 93 | var szDirPath = WebVideoCtrl.I_OpenFileDlg(iType); 94 | 95 | if (szDirPath != -1 && szDirPath != "" && szDirPath != null) { 96 | $("#" + id).val(szDirPath); 97 | } 98 | } 99 | 100 | // 获取本地参数 101 | function clickGetLocalCfg() { 102 | var xmlDoc = WebVideoCtrl.I_GetLocalCfg(); 103 | 104 | $("#netsPreach").val($(xmlDoc).find("BuffNumberType").eq(0).text()); 105 | $("#wndSize").val($(xmlDoc).find("PlayWndType").eq(0).text()); 106 | $("#rulesInfo").val($(xmlDoc).find("IVSMode").eq(0).text()); 107 | $("#captureFileFormat").val($(xmlDoc).find("CaptureFileFormat").eq(0).text()); 108 | $("#packSize").val($(xmlDoc).find("PackgeSize").eq(0).text()); 109 | $("#recordPath").val($(xmlDoc).find("RecordPath").eq(0).text()); 110 | $("#downloadPath").val($(xmlDoc).find("DownloadPath").eq(0).text()); 111 | $("#previewPicPath").val($(xmlDoc).find("CapturePath").eq(0).text()); 112 | $("#playbackPicPath").val($(xmlDoc).find("PlaybackPicPath").eq(0).text()); 113 | $("#playbackFilePath").val($(xmlDoc).find("PlaybackFilePath").eq(0).text()); 114 | $("#protocolType").val($(xmlDoc).find("ProtocolType").eq(0).text()); 115 | 116 | showOPInfo("本地配置获取成功!"); 117 | } 118 | 119 | // 设置本地参数 120 | function clickSetLocalCfg() { 121 | var arrXml = [], 122 | szInfo = ""; 123 | 124 | arrXml.push(""); 125 | arrXml.push("" + $("#packSize").val() + ""); 126 | arrXml.push("" + $("#wndSize").val() + ""); 127 | arrXml.push("" + $("#netsPreach").val() + ""); 128 | arrXml.push("" + $("#recordPath").val() + ""); 129 | arrXml.push("" + $("#previewPicPath").val() + ""); 130 | arrXml.push("" + $("#playbackFilePath").val() + ""); 131 | arrXml.push("" + $("#playbackPicPath").val() + ""); 132 | arrXml.push("" + $("#downloadPath").val() + ""); 133 | arrXml.push("" + $("#rulesInfo").val() + ""); 134 | arrXml.push("" + $("#captureFileFormat").val() + ""); 135 | arrXml.push("" + $("#protocolType").val() + ""); 136 | arrXml.push(""); 137 | 138 | var iRet = WebVideoCtrl.I_SetLocalCfg(arrXml.join("")); 139 | 140 | if (0 == iRet) { 141 | szInfo = "本地配置设置成功!"; 142 | } else { 143 | szInfo = "本地配置设置失败!"; 144 | } 145 | showOPInfo(szInfo); 146 | } 147 | 148 | // 窗口分割数 149 | function changeWndNum(iType) { 150 | iType = parseInt(iType, 10); 151 | WebVideoCtrl.I_ChangeWndNum(iType); 152 | } 153 | 154 | // 登录 155 | function clickLogin() { 156 | var szIP = $("#loginip").val(), 157 | szPort = $("#port").val(), 158 | szUsername = $("#username").val(), 159 | szPassword = $("#password").val(); 160 | 161 | if ("" == szIP || "" == szPort) { 162 | return; 163 | } 164 | 165 | var iRet = WebVideoCtrl.I_Login(szIP, 1, szPort, szUsername, szPassword, { 166 | success: function (xmlDoc) { 167 | showOPInfo(szIP + " 登录成功!"); 168 | 169 | $("#ip").prepend(""); 170 | setTimeout(function () { 171 | $("#ip").val(szIP); 172 | getChannelInfo(); 173 | }, 10); 174 | }, 175 | error: function () { 176 | showOPInfo(szIP + " 登录失败!"); 177 | } 178 | }); 179 | 180 | if (-1 == iRet) { 181 | showOPInfo(szIP + " 已登录过!"); 182 | } 183 | } 184 | 185 | // 退出 186 | function clickLogout() { 187 | var szIP = $("#ip").val(), 188 | szInfo = ""; 189 | 190 | if (szIP == "") { 191 | return; 192 | } 193 | 194 | var iRet = WebVideoCtrl.I_Logout(szIP); 195 | if (0 == iRet) { 196 | szInfo = "退出成功!"; 197 | 198 | $("#ip option[value='" + szIP + "']").remove(); 199 | getChannelInfo(); 200 | } else { 201 | szInfo = "退出失败!"; 202 | } 203 | showOPInfo(szIP + " " + szInfo); 204 | } 205 | 206 | // 获取设备信息 207 | function clickGetDeviceInfo() { 208 | var szIP = $("#ip").val(); 209 | 210 | if ("" == szIP) { 211 | return; 212 | } 213 | 214 | WebVideoCtrl.I_GetDeviceInfo(szIP, { 215 | success: function (xmlDoc) { 216 | var arrStr = []; 217 | arrStr.push("设备名称:" + $(xmlDoc).find("deviceName").eq(0).text() + "\r\n"); 218 | arrStr.push("设备ID:" + $(xmlDoc).find("deviceID").eq(0).text() + "\r\n"); 219 | arrStr.push("型号:" + $(xmlDoc).find("model").eq(0).text() + "\r\n"); 220 | arrStr.push("设备序列号:" + $(xmlDoc).find("serialNumber").eq(0).text() + "\r\n"); 221 | arrStr.push("MAC地址:" + $(xmlDoc).find("macAddress").eq(0).text() + "\r\n"); 222 | arrStr.push("主控版本:" + $(xmlDoc).find("firmwareVersion").eq(0).text() + " " + $(xmlDoc).find("firmwareReleasedDate").eq(0).text() + "\r\n"); 223 | arrStr.push("编码版本:" + $(xmlDoc).find("encoderVersion").eq(0).text() + " " + $(xmlDoc).find("encoderReleasedDate").eq(0).text() + "\r\n"); 224 | 225 | showOPInfo(szIP + " 获取设备信息成功!"); 226 | alert(arrStr.join("")); 227 | }, 228 | error: function () { 229 | showOPInfo(szIP + " 获取设备信息失败!"); 230 | } 231 | }); 232 | } 233 | 234 | // 获取通道 235 | function getChannelInfo() { 236 | var szIP = $("#ip").val(), 237 | oSel = $("#channels").empty(), 238 | nAnalogChannel = 0; 239 | 240 | if ("" == szIP) { 241 | return; 242 | } 243 | 244 | // 模拟通道 245 | WebVideoCtrl.I_GetAnalogChannelInfo(szIP, { 246 | async: false, 247 | success: function (xmlDoc) { 248 | var oChannels = $(xmlDoc).find("VideoInputChannel"); 249 | nAnalogChannel = oChannels.length; 250 | 251 | $.each(oChannels, function (i) { 252 | var id = parseInt($(this).find("id").eq(0).text(), 10), 253 | name = $(this).find("name").eq(0).text(); 254 | if ("" == name) { 255 | name = "Camera " + (id < 9 ? "0" + id : id); 256 | } 257 | oSel.append(""); 258 | }); 259 | showOPInfo(szIP + " 获取模拟通道成功!"); 260 | }, 261 | error: function () { 262 | showOPInfo(szIP + " 获取模拟通道失败!"); 263 | } 264 | }); 265 | // 数字通道 266 | WebVideoCtrl.I_GetDigitalChannelInfo(szIP, { 267 | async: false, 268 | success: function (xmlDoc) { 269 | var oChannels = $(xmlDoc).find("InputProxyChannelStatus"); 270 | 271 | $.each(oChannels, function (i) { 272 | var id = parseInt($(this).find("id").eq(0).text(), 10), 273 | name = $(this).find("name").eq(0).text(), 274 | online = $(this).find("online").eq(0).text(); 275 | if ("false" == online) {// 过滤禁用的数字通道 276 | return true; 277 | } 278 | if ("" == name) { 279 | name = "IPCamera " + ((id - nAnalogChannel) < 9 ? "0" + (id - nAnalogChannel) : (id - nAnalogChannel)); 280 | } 281 | oSel.append(""); 282 | }); 283 | showOPInfo(szIP + " 获取数字通道成功!"); 284 | }, 285 | error: function () { 286 | showOPInfo(szIP + " 获取数字通道失败!"); 287 | } 288 | }); 289 | // 零通道 290 | WebVideoCtrl.I_GetZeroChannelInfo(szIP, { 291 | async: false, 292 | success: function (xmlDoc) { 293 | var oChannels = $(xmlDoc).find("ZeroVideoChannel"); 294 | 295 | $.each(oChannels, function (i) { 296 | var id = parseInt($(this).find("id").eq(0).text(), 10), 297 | name = $(this).find("name").eq(0).text(); 298 | if ("" == name) { 299 | name = "Zero Channel " + (id < 9 ? "0" + id : id); 300 | } 301 | if ("true" == $(this).find("enabled").eq(0).text()) {// 过滤禁用的零通道 302 | oSel.append(""); 303 | } 304 | }); 305 | showOPInfo(szIP + " 获取零通道成功!"); 306 | }, 307 | error: function () { 308 | showOPInfo(szIP + " 获取零通道失败!"); 309 | } 310 | }); 311 | } 312 | 313 | // 获取数字通道 314 | function clickGetDigitalChannelInfo() { 315 | var szIP = $("#ip").val(), 316 | iAnalogChannelNum = 0; 317 | 318 | $("#digitalchannellist").empty(); 319 | 320 | if ("" == szIP) { 321 | return; 322 | } 323 | 324 | // 模拟通道 325 | WebVideoCtrl.I_GetAnalogChannelInfo(szIP, { 326 | async: false, 327 | success: function (xmlDoc) { 328 | iAnalogChannelNum = $(xmlDoc).find("VideoInputChannel").length; 329 | }, 330 | error: function () { 331 | 332 | } 333 | }); 334 | 335 | // 数字通道 336 | WebVideoCtrl.I_GetDigitalChannelInfo(szIP, { 337 | async: false, 338 | success: function (xmlDoc) { 339 | var oChannels = $(xmlDoc).find("InputProxyChannelStatus"); 340 | 341 | $.each(oChannels, function () { 342 | var id = parseInt($(this).find("id").eq(0).text(), 10), 343 | ipAddress = $(this).find("ipAddress").eq(0).text(), 344 | srcInputPort = $(this).find("srcInputPort").eq(0).text(), 345 | managePortNo = $(this).find("managePortNo").eq(0).text(), 346 | online = $(this).find("online").eq(0).text(), 347 | proxyProtocol = $(this).find("proxyProtocol").eq(0).text(); 348 | 349 | var objTr = $("#digitalchannellist").get(0).insertRow(-1); 350 | var objTd = objTr.insertCell(0); 351 | objTd.innerHTML = (id - iAnalogChannelNum) < 10 ? "D0" + (id - iAnalogChannelNum) : "D" + (id - iAnalogChannelNum); 352 | objTd = objTr.insertCell(1); 353 | objTd.width = "25%"; 354 | objTd.innerHTML = ipAddress; 355 | objTd = objTr.insertCell(2); 356 | objTd.width = "15%"; 357 | objTd.innerHTML = srcInputPort; 358 | objTd = objTr.insertCell(3); 359 | objTd.width = "20%"; 360 | objTd.innerHTML = managePortNo; 361 | objTd = objTr.insertCell(4); 362 | objTd.width = "15%"; 363 | objTd.innerHTML = "true" == online ? "在线" : "离线"; 364 | objTd = objTr.insertCell(5); 365 | objTd.width = "25%"; 366 | objTd.innerHTML = proxyProtocol; 367 | }); 368 | showOPInfo(szIP + " 获取数字通道成功!"); 369 | }, 370 | error: function () { 371 | showOPInfo(szIP + " 没有数字通道!"); 372 | } 373 | }); 374 | } 375 | 376 | // 开始预览 377 | function clickStartRealPlay() { 378 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 379 | szIP = $("#ip").val(), 380 | iStreamType = parseInt($("#streamtype").val(), 10), 381 | iChannelID = parseInt($("#channels").val(), 10), 382 | bZeroChannel = $("#channels option").eq($("#channels").get(0).selectedIndex).attr("bZero") == "true" ? true : false, 383 | szInfo = ""; 384 | 385 | if ("" == szIP) { 386 | return; 387 | } 388 | 389 | if (oWndInfo != null) {// 已经在播放了,先停止 390 | WebVideoCtrl.I_Stop(); 391 | } 392 | 393 | var iRet = WebVideoCtrl.I_StartRealPlay(szIP, { 394 | iStreamType: iStreamType, 395 | iChannelID: iChannelID, 396 | bZeroChannel: bZeroChannel 397 | }); 398 | 399 | if (0 == iRet) { 400 | szInfo = "开始预览成功!"; 401 | } else { 402 | szInfo = "开始预览失败!"; 403 | } 404 | 405 | showOPInfo(szIP + " " + szInfo); 406 | } 407 | 408 | // 停止预览 409 | function clickStopRealPlay() { 410 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 411 | szInfo = ""; 412 | 413 | if (oWndInfo != null) { 414 | var iRet = WebVideoCtrl.I_Stop(); 415 | if (0 == iRet) { 416 | szInfo = "停止预览成功!"; 417 | } else { 418 | szInfo = "停止预览失败!"; 419 | } 420 | showOPInfo(oWndInfo.szIP + " " + szInfo); 421 | } 422 | } 423 | 424 | // 打开声音 425 | function clickOpenSound() { 426 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 427 | szInfo = ""; 428 | 429 | if (oWndInfo != null) { 430 | var allWndInfo = WebVideoCtrl.I_GetWindowStatus(); 431 | // 循环遍历所有窗口,如果有窗口打开了声音,先关闭 432 | for (var i = 0, iLen = allWndInfo.length; i < iLen; i++) { 433 | oWndInfo = allWndInfo[i]; 434 | if (oWndInfo.bSound) { 435 | WebVideoCtrl.I_CloseSound(oWndInfo.iIndex); 436 | break; 437 | } 438 | } 439 | 440 | var iRet = WebVideoCtrl.I_OpenSound(); 441 | 442 | if (0 == iRet) { 443 | szInfo = "打开声音成功!"; 444 | } else { 445 | szInfo = "打开声音失败!"; 446 | } 447 | showOPInfo(oWndInfo.szIP + " " + szInfo); 448 | } 449 | } 450 | 451 | // 关闭声音 452 | function clickCloseSound() { 453 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 454 | szInfo = ""; 455 | 456 | if (oWndInfo != null) { 457 | var iRet = WebVideoCtrl.I_CloseSound(); 458 | if (0 == iRet) { 459 | szInfo = "关闭声音成功!"; 460 | } else { 461 | szInfo = "关闭声音失败!"; 462 | } 463 | showOPInfo(oWndInfo.szIP + " " + szInfo); 464 | } 465 | } 466 | 467 | // 设置音量 468 | function clickSetVolume() { 469 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 470 | iVolume = parseInt($("#volume").val(), 10), 471 | szInfo = ""; 472 | 473 | if (oWndInfo != null) { 474 | var iRet = WebVideoCtrl.I_SetVolume(iVolume); 475 | if (0 == iRet) { 476 | szInfo = "音量设置成功!"; 477 | } else { 478 | szInfo = "音量设置失败!"; 479 | } 480 | showOPInfo(oWndInfo.szIP + " " + szInfo); 481 | } 482 | } 483 | 484 | // 抓图 485 | function clickCapturePic() { 486 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 487 | szInfo = ""; 488 | 489 | if (oWndInfo != null) { 490 | var szChannelID = $("#channels").val(), 491 | szPicName = oWndInfo.szIP + "_" + szChannelID + "_" + new Date().getTime(), 492 | iRet = WebVideoCtrl.I_CapturePic(szPicName); 493 | if (0 == iRet) { 494 | szInfo = "抓图成功!"; 495 | } else { 496 | szInfo = "抓图失败!"; 497 | } 498 | showOPInfo(oWndInfo.szIP + " " + szInfo); 499 | } 500 | } 501 | 502 | // 开始录像 503 | function clickStartRecord() { 504 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 505 | szInfo = ""; 506 | 507 | if (oWndInfo != null) { 508 | var szChannelID = $("#channels").val(), 509 | szFileName = oWndInfo.szIP + "_" + szChannelID + "_" + new Date().getTime(), 510 | iRet = WebVideoCtrl.I_StartRecord(szFileName); 511 | if (0 == iRet) { 512 | szInfo = "开始录像成功!"; 513 | } else { 514 | szInfo = "开始录像失败!"; 515 | } 516 | showOPInfo(oWndInfo.szIP + " " + szInfo); 517 | } 518 | } 519 | 520 | // 停止录像 521 | function clickStopRecord() { 522 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 523 | szInfo = ""; 524 | 525 | if (oWndInfo != null) { 526 | var iRet = WebVideoCtrl.I_StopRecord(); 527 | if (0 == iRet) { 528 | szInfo = "停止录像成功!"; 529 | } else { 530 | szInfo = "停止录像失败!"; 531 | } 532 | showOPInfo(oWndInfo.szIP + " " + szInfo); 533 | } 534 | } 535 | 536 | // 获取对讲通道 537 | function clickGetAudioInfo() { 538 | var szIP = $("#ip").val(); 539 | 540 | if ("" == szIP) { 541 | return; 542 | } 543 | 544 | WebVideoCtrl.I_GetAudioInfo(szIP, { 545 | success: function (xmlDoc) { 546 | var oAudioChannels = $(xmlDoc).find("TwoWayAudioChannel"), 547 | oSel = $("#audiochannels").empty(); 548 | $.each(oAudioChannels, function () { 549 | var id = $(this).find("id").eq(0).text(); 550 | 551 | oSel.append(""); 552 | }); 553 | showOPInfo(szIP + " 获取对讲通道成功!"); 554 | }, 555 | error: function () { 556 | showOPInfo(szIP + " 获取对讲通道失败!"); 557 | } 558 | }); 559 | } 560 | 561 | // 开始对讲 562 | function clickStartVoiceTalk() { 563 | var szIP = $("#ip").val(), 564 | iAudioChannel = parseInt($("#audiochannels").val(), 10), 565 | szInfo = ""; 566 | 567 | if ("" == szIP) { 568 | return; 569 | } 570 | 571 | if (isNaN(iAudioChannel)){ 572 | alert("请选择对讲通道!"); 573 | return; 574 | } 575 | 576 | var iRet = WebVideoCtrl.I_StartVoiceTalk(szIP, iAudioChannel); 577 | 578 | if (0 == iRet) { 579 | szInfo = "开始对讲成功!"; 580 | } else { 581 | szInfo = "开始对讲失败!"; 582 | } 583 | showOPInfo(szIP + " " + szInfo); 584 | } 585 | 586 | // 停止对讲 587 | function clickStopVoiceTalk() { 588 | var szIP = $("#ip").val(), 589 | iRet = WebVideoCtrl.I_StopVoiceTalk(), 590 | szInfo = ""; 591 | 592 | if ("" == szIP) { 593 | return; 594 | } 595 | 596 | if (0 == iRet) { 597 | szInfo = "停止对讲成功!"; 598 | } else { 599 | szInfo = "停止对讲失败!"; 600 | } 601 | showOPInfo(szIP + " " + szInfo); 602 | } 603 | 604 | // 启用电子放大 605 | function clickEnableEZoom() { 606 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 607 | szInfo = ""; 608 | 609 | if (oWndInfo != null) { 610 | var iRet = WebVideoCtrl.I_EnableEZoom(); 611 | if (0 == iRet) { 612 | szInfo = "启用电子放大成功!"; 613 | } else { 614 | szInfo = "启用电子放大失败!"; 615 | } 616 | showOPInfo(oWndInfo.szIP + " " + szInfo); 617 | } 618 | } 619 | 620 | // 禁用电子放大 621 | function clickDisableEZoom() { 622 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 623 | szInfo = ""; 624 | 625 | if (oWndInfo != null) { 626 | var iRet = WebVideoCtrl.I_DisableEZoom(); 627 | if (0 == iRet) { 628 | szInfo = "禁用电子放大成功!"; 629 | } else { 630 | szInfo = "禁用电子放大失败!"; 631 | } 632 | showOPInfo(oWndInfo.szIP + " " + szInfo); 633 | } 634 | } 635 | 636 | // 启用3D放大 637 | function clickEnable3DZoom() { 638 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 639 | szInfo = ""; 640 | 641 | if (oWndInfo != null) { 642 | var iRet = WebVideoCtrl.I_Enable3DZoom(); 643 | if (0 == iRet) { 644 | szInfo = "启用3D放大成功!"; 645 | } else { 646 | szInfo = "启用3D放大失败!"; 647 | } 648 | showOPInfo(oWndInfo.szIP + " " + szInfo); 649 | } 650 | } 651 | 652 | // 禁用3D放大 653 | function clickDisable3DZoom() { 654 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 655 | szInfo = ""; 656 | 657 | if (oWndInfo != null) { 658 | var iRet = WebVideoCtrl.I_Disable3DZoom(); 659 | if (0 == iRet) { 660 | szInfo = "禁用3D放大成功!"; 661 | } else { 662 | szInfo = "禁用3D放大失败!"; 663 | } 664 | showOPInfo(oWndInfo.szIP + " " + szInfo); 665 | } 666 | } 667 | 668 | // 全屏 669 | function clickFullScreen() { 670 | WebVideoCtrl.I_FullScreen(true); 671 | } 672 | 673 | // PTZ控制 9为自动,1,2,3,4,5,6,7,8为方向PTZ 674 | var g_bPTZAuto = false; 675 | function mouseDownPTZControl(iPTZIndex) { 676 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 677 | bZeroChannel = $("#channels option").eq($("#channels").get(0).selectedIndex).attr("bZero") == "true" ? true : false, 678 | iPTZSpeed = $("#ptzspeed").val(), 679 | bStop = false; 680 | 681 | if (bZeroChannel) {// 零通道不支持云台 682 | return; 683 | } 684 | 685 | if (oWndInfo != null) { 686 | if (9 == iPTZIndex && g_bPTZAuto) { 687 | iPTZSpeed = 0;// 自动开启后,速度置为0可以关闭自动 688 | bStop = true; 689 | } else { 690 | g_bPTZAuto = false;// 点击其他方向,自动肯定会被关闭 691 | bStop = false; 692 | } 693 | 694 | WebVideoCtrl.I_PTZControl(iPTZIndex, bStop, { 695 | iPTZSpeed: iPTZSpeed, 696 | success: function (xmlDoc) { 697 | if (9 == iPTZIndex) { 698 | g_bPTZAuto = !g_bPTZAuto; 699 | } 700 | showOPInfo(oWndInfo.szIP + " 开启云台成功!"); 701 | }, 702 | error: function () { 703 | showOPInfo(oWndInfo.szIP + " 开启云台失败!"); 704 | } 705 | }); 706 | } 707 | } 708 | 709 | // 方向PTZ停止 710 | function mouseUpPTZControl() { 711 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex); 712 | 713 | if (oWndInfo != null) { 714 | WebVideoCtrl.I_PTZControl(1, true, { 715 | success: function (xmlDoc) { 716 | showOPInfo(oWndInfo.szIP + " 停止云台成功!"); 717 | }, 718 | error: function () { 719 | showOPInfo(oWndInfo.szIP + " 停止云台失败!"); 720 | } 721 | }); 722 | } 723 | } 724 | 725 | // 设置预置点 726 | function clickSetPreset() { 727 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 728 | iPresetID = parseInt($("#preset").val(), 10); 729 | 730 | if (oWndInfo != null) { 731 | WebVideoCtrl.I_SetPreset(iPresetID, { 732 | success: function (xmlDoc) { 733 | showOPInfo(oWndInfo.szIP + " 设置预置点成功!"); 734 | }, 735 | error: function () { 736 | showOPInfo(oWndInfo.szIP + " 设置预置点失败!"); 737 | } 738 | }); 739 | } 740 | } 741 | 742 | // 调用预置点 743 | function clickGoPreset() { 744 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 745 | iPresetID = parseInt($("#preset").val(), 10); 746 | 747 | if (oWndInfo != null) { 748 | WebVideoCtrl.I_GoPreset(iPresetID, { 749 | success: function (xmlDoc) { 750 | showOPInfo(oWndInfo.szIP + " 调用预置点成功!"); 751 | }, 752 | error: function () { 753 | showOPInfo(oWndInfo.szIP + " 调用预置点失败!"); 754 | } 755 | }); 756 | } 757 | } 758 | 759 | // 搜索录像 760 | var iSearchTimes = 0; 761 | function clickRecordSearch(iType) { 762 | var szIP = $("#ip").val(), 763 | iChannelID = $("#channels").val(), 764 | bZeroChannel = $("#channels option").eq($("#channels").get(0).selectedIndex).attr("bZero") == "true" ? true : false, 765 | szStartTime = $("#starttime").val(), 766 | szEndTime = $("#endtime").val(); 767 | 768 | if ("" == szIP) { 769 | return; 770 | } 771 | 772 | if (bZeroChannel) {// 零通道不支持录像搜索 773 | return; 774 | } 775 | 776 | if (0 == iType) {// 首次搜索 777 | $("#searchlist").empty(); 778 | iSearchTimes = 0; 779 | } 780 | 781 | WebVideoCtrl.I_RecordSearch(szIP, iChannelID, szStartTime, szEndTime, { 782 | iSearchPos: iSearchTimes * 40, 783 | success: function (xmlDoc) { 784 | if("MORE" === $(xmlDoc).find("responseStatusStrg").eq(0).text()) { 785 | 786 | for(var i = 0, nLen = $(xmlDoc).find("searchMatchItem").length; i < nLen; i++) { 787 | var szPlaybackURI = $(xmlDoc).find("playbackURI").eq(i).text(); 788 | if(szPlaybackURI.indexOf("name=") < 0) { 789 | break; 790 | } 791 | var szStartTime = $(xmlDoc).find("startTime").eq(i).text(); 792 | var szEndTime = $(xmlDoc).find("endTime").eq(i).text(); 793 | var szFileName = szPlaybackURI.substring(szPlaybackURI.indexOf("name=") + 5, szPlaybackURI.indexOf("&size=")); 794 | 795 | var objTr = $("#searchlist").get(0).insertRow(-1); 796 | var objTd = objTr.insertCell(0); 797 | objTd.id = "downloadTd" + i; 798 | objTd.innerHTML = iSearchTimes * 40 + (i + 1); 799 | objTd = objTr.insertCell(1); 800 | objTd.width = "30%"; 801 | objTd.innerHTML = szFileName; 802 | objTd = objTr.insertCell(2); 803 | objTd.width = "30%"; 804 | objTd.innerHTML = (szStartTime.replace("T", " ")).replace("Z", ""); 805 | objTd = objTr.insertCell(3); 806 | objTd.width = "30%"; 807 | objTd.innerHTML = (szEndTime.replace("T", " ")).replace("Z", ""); 808 | objTd = objTr.insertCell(4); 809 | objTd.width = "10%"; 810 | objTd.innerHTML = "下载"; 811 | $("#downloadTd" + i).data("playbackURI", szPlaybackURI); 812 | } 813 | 814 | iSearchTimes++; 815 | clickRecordSearch(1);// 继续搜索 816 | } else if ("OK" === $(xmlDoc).find("responseStatusStrg").eq(0).text()) { 817 | var iLength = $(xmlDoc).find("searchMatchItem").length; 818 | for(var i = 0; i < iLength; i++) { 819 | var szPlaybackURI = $(xmlDoc).find("playbackURI").eq(i).text(); 820 | if(szPlaybackURI.indexOf("name=") < 0) { 821 | break; 822 | } 823 | var szStartTime = $(xmlDoc).find("startTime").eq(i).text(); 824 | var szEndTime = $(xmlDoc).find("endTime").eq(i).text(); 825 | var szFileName = szPlaybackURI.substring(szPlaybackURI.indexOf("name=") + 5, szPlaybackURI.indexOf("&size=")); 826 | 827 | var objTr = $("#searchlist").get(0).insertRow(-1); 828 | var objTd = objTr.insertCell(0); 829 | objTd.id = "downloadTd" + i; 830 | objTd.innerHTML = iSearchTimes * 40 + (i + 1); 831 | objTd = objTr.insertCell(1); 832 | objTd.width = "30%"; 833 | objTd.innerHTML = szFileName; 834 | objTd = objTr.insertCell(2); 835 | objTd.width = "30%"; 836 | objTd.innerHTML = (szStartTime.replace("T", " ")).replace("Z", ""); 837 | objTd = objTr.insertCell(3); 838 | objTd.width = "30%"; 839 | objTd.innerHTML = (szEndTime.replace("T", " ")).replace("Z", ""); 840 | objTd = objTr.insertCell(4); 841 | objTd.width = "10%"; 842 | objTd.innerHTML = "下载"; 843 | $("#downloadTd" + i).data("playbackURI", szPlaybackURI); 844 | } 845 | showOPInfo(szIP + " 搜索录像文件成功!"); 846 | } else if("NO MATCHES" === $(xmlDoc).find("responseStatusStrg").eq(0).text()) { 847 | setTimeout(function() { 848 | showOPInfo(szIP + " 没有录像文件!"); 849 | }, 50); 850 | } 851 | }, 852 | error: function () { 853 | showOPInfo(szIP + " 搜索录像文件失败!"); 854 | } 855 | }); 856 | } 857 | 858 | // 开始回放 859 | function clickStartPlayback() { 860 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 861 | szIP = $("#ip").val(), 862 | bZeroChannel = $("#channels option").eq($("#channels").get(0).selectedIndex).attr("bZero") == "true" ? true : false, 863 | iChannelID = $("#channels").val(), 864 | szStartTime = $("#starttime").val(), 865 | szEndTime = $("#endtime").val(), 866 | szInfo = "", 867 | bChecked = $("#transstream").prop("checked"), 868 | iRet = -1; 869 | 870 | if ("" == szIP) { 871 | return; 872 | } 873 | 874 | if (bZeroChannel) {// 零通道不支持回放 875 | return; 876 | } 877 | 878 | if (oWndInfo != null) {// 已经在播放了,先停止 879 | WebVideoCtrl.I_Stop(); 880 | } 881 | 882 | if (bChecked) {// 启用转码回放 883 | var oTransCodeParam = { 884 | 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:22 885 | TransResolution: "2",// 255:Auto,3:4CIF,2:QCIF,1:CIF 886 | TransBitrate: "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 887 | }; 888 | iRet = WebVideoCtrl.I_StartPlayback(szIP, { 889 | iChannelID: iChannelID, 890 | szStartTime: szStartTime, 891 | szEndTime: szEndTime, 892 | oTransCodeParam: oTransCodeParam 893 | }); 894 | } else { 895 | iRet = WebVideoCtrl.I_StartPlayback(szIP, { 896 | iChannelID: iChannelID, 897 | szStartTime: szStartTime, 898 | szEndTime: szEndTime 899 | }); 900 | } 901 | 902 | if (0 == iRet) { 903 | szInfo = "开始回放成功!"; 904 | } else { 905 | szInfo = "开始回放失败!"; 906 | } 907 | showOPInfo(szIP + " " + szInfo); 908 | } 909 | 910 | // 停止回放 911 | function clickStopPlayback() { 912 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 913 | szInfo = ""; 914 | 915 | if (oWndInfo != null) { 916 | var iRet = WebVideoCtrl.I_Stop(); 917 | if (0 == iRet) { 918 | szInfo = "停止回放成功!"; 919 | } else { 920 | szInfo = "停止回放失败!"; 921 | } 922 | showOPInfo(oWndInfo.szIP + " " + szInfo); 923 | } 924 | } 925 | 926 | // 开始倒放 927 | function clickReversePlayback() { 928 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 929 | szIP = $("#ip").val(), 930 | bZeroChannel = $("#channels option").eq($("#channels").get(0).selectedIndex).attr("bZero") == "true" ? true : false, 931 | iChannelID = $("#channels").val(), 932 | szStartTime = $("#starttime").val(), 933 | szEndTime = $("#endtime").val(), 934 | szInfo = ""; 935 | 936 | if ("" == szIP) { 937 | return; 938 | } 939 | 940 | if (bZeroChannel) {// 零通道不支持回放 941 | return; 942 | } 943 | 944 | if (oWndInfo != null) {// 已经在播放了,先停止 945 | WebVideoCtrl.I_Stop(); 946 | } 947 | 948 | var iRet = WebVideoCtrl.I_ReversePlayback(szIP, { 949 | iChannelID: iChannelID, 950 | szStartTime: szStartTime, 951 | szEndTime: szEndTime 952 | }); 953 | 954 | if (0 == iRet) { 955 | szInfo = "开始倒放成功!"; 956 | } else { 957 | szInfo = "开始倒放失败!"; 958 | } 959 | showOPInfo(szIP + " " + szInfo); 960 | } 961 | 962 | // 单帧 963 | function clickFrame() { 964 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 965 | szInfo = ""; 966 | 967 | if (oWndInfo != null) { 968 | var iRet = WebVideoCtrl.I_Frame(); 969 | if (0 == iRet) { 970 | szInfo = "单帧播放成功!"; 971 | } else { 972 | szInfo = "单帧播放失败!"; 973 | } 974 | showOPInfo(oWndInfo.szIP + " " + szInfo); 975 | } 976 | } 977 | 978 | // 暂停 979 | function clickPause() { 980 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 981 | szInfo = ""; 982 | 983 | if (oWndInfo != null) { 984 | var iRet = WebVideoCtrl.I_Pause(); 985 | if (0 == iRet) { 986 | szInfo = "暂停成功!"; 987 | } else { 988 | szInfo = "暂停失败!"; 989 | } 990 | showOPInfo(oWndInfo.szIP + " " + szInfo); 991 | } 992 | } 993 | 994 | // 恢复 995 | function clickResume() { 996 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 997 | szInfo = ""; 998 | 999 | if (oWndInfo != null) { 1000 | var iRet = WebVideoCtrl.I_Resume(); 1001 | if (0 == iRet) { 1002 | szInfo = "恢复成功!"; 1003 | } else { 1004 | szInfo = "恢复失败!"; 1005 | } 1006 | showOPInfo(oWndInfo.szIP + " " + szInfo); 1007 | } 1008 | } 1009 | 1010 | // 慢放 1011 | function clickPlaySlow() { 1012 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 1013 | szInfo = ""; 1014 | 1015 | if (oWndInfo != null) { 1016 | var iRet = WebVideoCtrl.I_PlaySlow(); 1017 | if (0 == iRet) { 1018 | szInfo = "慢放成功!"; 1019 | } else { 1020 | szInfo = "慢放失败!"; 1021 | } 1022 | showOPInfo(oWndInfo.szIP + " " + szInfo); 1023 | } 1024 | } 1025 | 1026 | // 快放 1027 | function clickPlayFast() { 1028 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 1029 | szInfo = ""; 1030 | 1031 | if (oWndInfo != null) { 1032 | var iRet = WebVideoCtrl.I_PlayFast(); 1033 | if (0 == iRet) { 1034 | szInfo = "快放成功!"; 1035 | } else { 1036 | szInfo = "快放失败!"; 1037 | } 1038 | showOPInfo(oWndInfo.szIP + " " + szInfo); 1039 | } 1040 | } 1041 | 1042 | // OSD时间 1043 | function clickGetOSDTime() { 1044 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex); 1045 | 1046 | if (oWndInfo != null) { 1047 | var szTime = WebVideoCtrl.I_GetOSDTime(); 1048 | if (szTime != -1) { 1049 | $("#osdtime").val(szTime); 1050 | showOPInfo(oWndInfo.szIP + " 获取OSD时间成功!"); 1051 | } else { 1052 | showOPInfo(oWndInfo.szIP + " 获取OSD时间失败!"); 1053 | } 1054 | } 1055 | } 1056 | 1057 | // 下载录像 1058 | var iDownloadID = -1; 1059 | var tDownloadProcess = 0; 1060 | function clickStartDownloadRecord(i) { 1061 | var szIP = $("#ip").val(), 1062 | szChannelID = $("#channels").val(), 1063 | szFileName = szIP + "_" + szChannelID + "_" + new Date().getTime(), 1064 | szPlaybackURI = $("#downloadTd" + i).data("playbackURI"); 1065 | 1066 | if ("" == szIP) { 1067 | return; 1068 | } 1069 | 1070 | iDownloadID = WebVideoCtrl.I_StartDownloadRecord(szIP, szPlaybackURI, szFileName); 1071 | 1072 | if (iDownloadID < 0) { 1073 | var iErrorValue = WebVideoCtrl.I_GetLastError(); 1074 | if (34 == iErrorValue) { 1075 | showOPInfo(szIP + " 已下载!"); 1076 | } else if (33 == iErrorValue) { 1077 | showOPInfo(szIP + " 空间不足!"); 1078 | } else { 1079 | showOPInfo(szIP + " 下载失败!"); 1080 | } 1081 | } else { 1082 | $("
").appendTo("body"); 1083 | tDownloadProcess = setInterval("downProcess(" + i + ")", 1000); 1084 | } 1085 | } 1086 | // 下载进度 1087 | function downProcess() { 1088 | var iStatus = WebVideoCtrl.I_GetDownloadStatus(iDownloadID); 1089 | if (0 == iStatus) { 1090 | $("#downProcess").css({ 1091 | width: $("#searchlist").width() + "px", 1092 | height: "100px", 1093 | lineHeight: "100px", 1094 | left: $("#searchlist").offset().left + "px", 1095 | top: $("#searchlist").offset().top + "px" 1096 | }); 1097 | var iProcess = WebVideoCtrl.I_GetDownloadProgress(iDownloadID); 1098 | if (iProcess < 0) { 1099 | clearInterval(tDownloadProcess); 1100 | tDownloadProcess = 0; 1101 | m_iDownloadID = -1; 1102 | } else if (iProcess < 100) { 1103 | $("#downProcess").text(iProcess + "%"); 1104 | } else { 1105 | $("#downProcess").text("100%"); 1106 | setTimeout(function () { 1107 | $("#downProcess").remove(); 1108 | }, 1000); 1109 | 1110 | WebVideoCtrl.I_StopDownloadRecord(iDownloadID); 1111 | 1112 | showOPInfo("录像下载完成"); 1113 | clearInterval(tDownloadProcess); 1114 | tDownloadProcess = 0; 1115 | m_iDownloadID = -1; 1116 | } 1117 | } else { 1118 | WebVideoCtrl.I_StopDownloadRecord(iDownloadID); 1119 | 1120 | clearInterval(tDownloadProcess); 1121 | tDownloadProcess = 0; 1122 | iDownloadID = -1; 1123 | } 1124 | } 1125 | 1126 | // 导出配置文件 1127 | function clickExportDeviceConfig() { 1128 | var szIP = $("#ip").val(), 1129 | szInfo = ""; 1130 | 1131 | if ("" == szIP) { 1132 | return; 1133 | } 1134 | 1135 | var iRet = WebVideoCtrl.I_ExportDeviceConfig(szIP); 1136 | 1137 | if (0 == iRet) { 1138 | szInfo = "导出配置文件成功!"; 1139 | } else { 1140 | szInfo = "导出配置文件失败!"; 1141 | } 1142 | showOPInfo(szIP + " " + szInfo); 1143 | } 1144 | 1145 | // 导入配置文件 1146 | function clickImportDeviceConfig() { 1147 | var szIP = $("#ip").val(), 1148 | szFileName = $("#configFile").val(); 1149 | 1150 | if ("" == szIP) { 1151 | return; 1152 | } 1153 | 1154 | if ("" == szFileName) { 1155 | alert("请选择配置文件!"); 1156 | return; 1157 | } 1158 | 1159 | var iRet = WebVideoCtrl.I_ImportDeviceConfig(szIP, szFileName); 1160 | 1161 | if (0 == iRet) { 1162 | WebVideoCtrl.I_Restart(szIP, { 1163 | success: function (xmlDoc) { 1164 | $("
重启中...
").appendTo("body"); 1165 | var oSize = getWindowSize(); 1166 | $("#restartDiv").css({ 1167 | width: oSize.width + "px", 1168 | height: oSize.height + "px", 1169 | lineHeight: oSize.height + "px", 1170 | left: 0, 1171 | top: 0 1172 | }); 1173 | setTimeout("reconnect('" + szIP + "')", 20000); 1174 | }, 1175 | error: function () { 1176 | showOPInfo(szIP + " 重启失败!"); 1177 | } 1178 | }); 1179 | } else { 1180 | showOPInfo(szIP + " 导入失败!"); 1181 | } 1182 | } 1183 | 1184 | // 重连 1185 | function reconnect(szIP) { 1186 | WebVideoCtrl.I_Reconnect(szIP, { 1187 | success: function (xmlDoc) { 1188 | $("#restartDiv").remove(); 1189 | }, 1190 | error: function () { 1191 | setTimeout(function () {reconnect(szIP);}, 5000); 1192 | } 1193 | }); 1194 | } 1195 | 1196 | // 开始升级 1197 | m_tUpgrade = 0; 1198 | function clickStartUpgrade(szIP) { 1199 | var szIP = $("#ip").val(), 1200 | szFileName = $("#upgradeFile").val(); 1201 | 1202 | if ("" == szIP) { 1203 | return; 1204 | } 1205 | 1206 | if ("" == szFileName) { 1207 | alert("请选择升级文件!"); 1208 | return; 1209 | } 1210 | 1211 | var iRet = WebVideoCtrl.I_StartUpgrade(szIP, szFileName); 1212 | if (0 == iRet) { 1213 | m_tUpgrade = setInterval("getUpgradeStatus('" + szIP + "')", 1000); 1214 | } else { 1215 | showOPInfo(szIP + " 升级失败!"); 1216 | } 1217 | } 1218 | 1219 | // 获取升级状态 1220 | function getUpgradeStatus(szIP) { 1221 | var iStatus = WebVideoCtrl.I_UpgradeStatus(); 1222 | if (iStatus == 0) { 1223 | var iProcess = WebVideoCtrl.I_UpgradeProgress(); 1224 | if (iProcess < 0) { 1225 | clearInterval(m_tUpgrade); 1226 | m_tUpgrade = 0; 1227 | showOPInfo(szIP + " 获取进度失败!"); 1228 | return; 1229 | } else if (iProcess < 100) { 1230 | if (0 == $("#restartDiv").length) { 1231 | $("
").appendTo("body"); 1232 | var oSize = getWindowSize(); 1233 | $("#restartDiv").css({ 1234 | width: oSize.width + "px", 1235 | height: oSize.height + "px", 1236 | lineHeight: oSize.height + "px", 1237 | left: 0, 1238 | top: 0 1239 | }); 1240 | } 1241 | $("#restartDiv").text(iProcess + "%"); 1242 | } else { 1243 | WebVideoCtrl.I_StopUpgrade(); 1244 | clearInterval(m_tUpgrade); 1245 | m_tUpgrade = 0; 1246 | 1247 | $("#restartDiv").remove(); 1248 | 1249 | WebVideoCtrl.I_Restart(szIP, { 1250 | success: function (xmlDoc) { 1251 | $("
重启中...
").appendTo("body"); 1252 | var oSize = getWindowSize(); 1253 | $("#restartDiv").css({ 1254 | width: oSize.width + "px", 1255 | height: oSize.height + "px", 1256 | lineHeight: oSize.height + "px", 1257 | left: 0, 1258 | top: 0 1259 | }); 1260 | setTimeout("reconnect('" + szIP + "')", 20000); 1261 | }, 1262 | error: function () { 1263 | showOPInfo(szIP + " 重启失败!"); 1264 | } 1265 | }); 1266 | } 1267 | } else if (iStatus == 1) { 1268 | WebVideoCtrl.I_StopUpgrade(); 1269 | showOPInfo(szIP + " 升级失败!"); 1270 | clearInterval(m_tUpgrade); 1271 | m_tUpgrade = 0; 1272 | } else if (iStatus == 2) { 1273 | mWebVideoCtrl.I_StopUpgrade(); 1274 | showOPInfo(szIP + " 语言不匹配!"); 1275 | clearInterval(m_tUpgrade); 1276 | m_tUpgrade = 0; 1277 | } else { 1278 | mWebVideoCtrl.I_StopUpgrade(); 1279 | showOPInfo(szIP + " 获取状态失败!"); 1280 | clearInterval(m_tUpgrade); 1281 | m_tUpgrade = 0; 1282 | } 1283 | } 1284 | 1285 | // 检查插件版本 1286 | function clickCheckPluginVersion() { 1287 | var iRet = WebVideoCtrl.I_CheckPluginVersion(); 1288 | if (0 == iRet) { 1289 | alert("您的插件版本已经是最新的!"); 1290 | } else { 1291 | alert("检测到新的插件版本!"); 1292 | } 1293 | } 1294 | 1295 | // 远程配置库 1296 | function clickRemoteConfig() { 1297 | var szIP = $("#ip").val(), 1298 | iDevicePort = parseInt($("#deviceport").val(), 10) || "", 1299 | szInfo = ""; 1300 | 1301 | if ("" == szIP) { 1302 | return; 1303 | } 1304 | 1305 | var iRet = WebVideoCtrl.I_RemoteConfig(szIP, { 1306 | iDevicePort: iDevicePort, 1307 | iLan: 1 1308 | }); 1309 | 1310 | if (-1 == iRet) { 1311 | szInfo = "调用远程配置库失败!"; 1312 | } else { 1313 | szInfo = "调用远程配置库成功!"; 1314 | } 1315 | showOPInfo(szIP + " " + szInfo); 1316 | } 1317 | 1318 | function clickRestoreDefault() { 1319 | var szIP = $("#ip").val(), 1320 | szMode = "basic"; 1321 | WebVideoCtrl.I_RestoreDefault(szIP, szMode, { 1322 | success: function (xmlDoc) { 1323 | $("#restartDiv").remove(); 1324 | showOPInfo(szIP + " 恢复默认参数成功!"); 1325 | //恢复完成后需要重启 1326 | WebVideoCtrl.I_Restart(szIP, { 1327 | success: function (xmlDoc) { 1328 | $("
重启中...
").appendTo("body"); 1329 | var oSize = getWindowSize(); 1330 | $("#restartDiv").css({ 1331 | width: oSize.width + "px", 1332 | height: oSize.height + "px", 1333 | lineHeight: oSize.height + "px", 1334 | left: 0, 1335 | top: 0 1336 | }); 1337 | setTimeout("reconnect('" + szIP + "')", 20000); 1338 | }, 1339 | error: function () { 1340 | showOPInfo(szIP + " 重启失败!"); 1341 | } 1342 | }); 1343 | }, 1344 | error: function () { 1345 | showOPInfo(szIP + " 恢复默认参数失败!"); 1346 | } 1347 | }); 1348 | } 1349 | 1350 | function PTZZoomIn() { 1351 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex); 1352 | 1353 | if (oWndInfo != null) { 1354 | WebVideoCtrl.I_PTZControl(10, false, { 1355 | iWndIndex: g_iWndIndex, 1356 | success: function (xmlDoc) { 1357 | showOPInfo(oWndInfo.szIP + " 调焦+成功!"); 1358 | }, 1359 | error: function () { 1360 | showOPInfo(oWndInfo.szIP + " 调焦+失败!"); 1361 | } 1362 | }); 1363 | } 1364 | } 1365 | 1366 | function PTZZoomout() { 1367 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex); 1368 | 1369 | if (oWndInfo != null) { 1370 | WebVideoCtrl.I_PTZControl(11, false, { 1371 | iWndIndex: g_iWndIndex, 1372 | success: function (xmlDoc) { 1373 | showOPInfo(oWndInfo.szIP + " 调焦-成功!"); 1374 | }, 1375 | error: function () { 1376 | showOPInfo(oWndInfo.szIP + " 调焦-失败!"); 1377 | } 1378 | }); 1379 | } 1380 | } 1381 | 1382 | function PTZZoomStop() { 1383 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex); 1384 | 1385 | if (oWndInfo != null) { 1386 | WebVideoCtrl.I_PTZControl(11, true, { 1387 | iWndIndex: g_iWndIndex, 1388 | success: function (xmlDoc) { 1389 | showOPInfo(oWndInfo.szIP + " 调焦停止成功!"); 1390 | }, 1391 | error: function () { 1392 | showOPInfo(oWndInfo.szIP + " 调焦停止失败!"); 1393 | } 1394 | }); 1395 | } 1396 | } 1397 | 1398 | function PTZFocusIn() { 1399 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex); 1400 | 1401 | if (oWndInfo != null) { 1402 | WebVideoCtrl.I_PTZControl(12, false, { 1403 | iWndIndex: g_iWndIndex, 1404 | success: function (xmlDoc) { 1405 | showOPInfo(oWndInfo.szIP + " 聚焦+成功!"); 1406 | }, 1407 | error: function () { 1408 | showOPInfo(oWndInfo.szIP + " 聚焦+失败!"); 1409 | } 1410 | }); 1411 | } 1412 | } 1413 | 1414 | function PTZFoucusOut() { 1415 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex); 1416 | 1417 | if (oWndInfo != null) { 1418 | WebVideoCtrl.I_PTZControl(13, false, { 1419 | iWndIndex: g_iWndIndex, 1420 | success: function (xmlDoc) { 1421 | showOPInfo(oWndInfo.szIP + " 聚焦-成功!"); 1422 | }, 1423 | error: function () { 1424 | showOPInfo(oWndInfo.szIP + " 聚焦-失败!"); 1425 | } 1426 | }); 1427 | } 1428 | } 1429 | 1430 | function PTZFoucusStop() { 1431 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex); 1432 | 1433 | if (oWndInfo != null) { 1434 | WebVideoCtrl.I_PTZControl(12, true, { 1435 | iWndIndex: g_iWndIndex, 1436 | success: function (xmlDoc) { 1437 | showOPInfo(oWndInfo.szIP + " 聚焦停止成功!"); 1438 | }, 1439 | error: function () { 1440 | showOPInfo(oWndInfo.szIP + " 聚焦停止失败!"); 1441 | } 1442 | }); 1443 | } 1444 | } 1445 | 1446 | function PTZIrisIn() { 1447 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex); 1448 | 1449 | if (oWndInfo != null) { 1450 | WebVideoCtrl.I_PTZControl(14, false, { 1451 | iWndIndex: g_iWndIndex, 1452 | success: function (xmlDoc) { 1453 | showOPInfo(oWndInfo.szIP + " 光圈+成功!"); 1454 | }, 1455 | error: function () { 1456 | showOPInfo(oWndInfo.szIP + " 光圈+失败!"); 1457 | } 1458 | }); 1459 | } 1460 | } 1461 | 1462 | function PTZIrisOut() { 1463 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex); 1464 | 1465 | if (oWndInfo != null) { 1466 | WebVideoCtrl.I_PTZControl(15, false, { 1467 | iWndIndex: g_iWndIndex, 1468 | success: function (xmlDoc) { 1469 | showOPInfo(oWndInfo.szIP + " 光圈-成功!"); 1470 | }, 1471 | error: function () { 1472 | showOPInfo(oWndInfo.szIP + " 光圈-失败!"); 1473 | } 1474 | }); 1475 | } 1476 | } 1477 | 1478 | function PTZIrisStop() { 1479 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex); 1480 | 1481 | if (oWndInfo != null) { 1482 | WebVideoCtrl.I_PTZControl(14, true, { 1483 | iWndIndex: g_iWndIndex, 1484 | success: function (xmlDoc) { 1485 | showOPInfo(oWndInfo.szIP + " 光圈停止成功!"); 1486 | }, 1487 | error: function () { 1488 | showOPInfo(oWndInfo.szIP + " 光圈停止失败!"); 1489 | } 1490 | }); 1491 | } 1492 | } 1493 | 1494 | dateFormat = function (oDate, fmt) { 1495 | var o = { 1496 | "M+": oDate.getMonth() + 1, //月份 1497 | "d+": oDate.getDate(), //日 1498 | "h+": oDate.getHours(), //小时 1499 | "m+": oDate.getMinutes(), //分 1500 | "s+": oDate.getSeconds(), //秒 1501 | "q+": Math.floor((oDate.getMonth() + 3) / 3), //季度 1502 | "S": oDate.getMilliseconds()//毫秒 1503 | }; 1504 | if(/(y+)/.test(fmt)) { 1505 | fmt = fmt.replace(RegExp.$1, (oDate.getFullYear() + "").substr(4 - RegExp.$1.length)); 1506 | } 1507 | for (var k in o) { 1508 | if(new RegExp("(" + k + ")").test(fmt)) { 1509 | fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); 1510 | } 1511 | } 1512 | return fmt; 1513 | }; 1514 | 1515 | // 切换模式 1516 | function changeIPMode(iType) { 1517 | var arrPort = [0, 7071, 80]; 1518 | 1519 | $("#serverport").val(arrPort[iType]); 1520 | } 1521 | 1522 | // 获取设备IP 1523 | function clickGetDeviceIP() { 1524 | var iDeviceMode = parseInt($("#devicemode").val(), 10), 1525 | szAddress = $("#serveraddress").val(), 1526 | iPort = parseInt($("#serverport").val(), 10) || 0, 1527 | szDeviceID = $("#deviceid").val(), 1528 | szDeviceInfo = ""; 1529 | 1530 | szDeviceInfo = WebVideoCtrl.I_GetIPInfoByMode(iDeviceMode, szAddress, iPort, szDeviceID); 1531 | 1532 | if ("" == szDeviceInfo) { 1533 | showOPInfo("设备IP和端口解析失败!"); 1534 | } else { 1535 | showOPInfo("设备IP和端口解析成功!"); 1536 | 1537 | var arrTemp = szDeviceInfo.split("-"); 1538 | $("#loginip").val(arrTemp[0]); 1539 | $("#deviceport").val(arrTemp[1]); 1540 | } 1541 | } -------------------------------------------------------------------------------- /example-cn/webVideoCtrl.js: -------------------------------------------------------------------------------- 1 | !function(e){if(!e.WebVideoCtrl){var t=function(){function t(){this.id=this.createUUID()}var n="100%",r="100%",o="",i="",a={szContainerID:"",szColorProperty:"",szOcxClassId:"clsid:E7EF736D-B4E6-4A5A-BA94-732D71107808",szMimeTypes:"application/hwp-webvideo-plugin",iWndowType:1,iPlayMode:2,bDebugMode:!1,cbSelWnd:null,cbEvent:null},c=null,u=0,l=[],p=[],d=null,P=null,h=null,I=null,f=this,m=null,C=1,S=2,y=200,g=0,v=1,x=2,T=3,z=4,D=5,A=6,b=0,M=2,q=3,L=21,R=0,G="IPCamera",X="IPDome",H="IPZoom",w="3,0,5,563,0,5,566,5,2,401,1,2,112,3,0,101,0,5,574,2,6,73,1,2,14";e.GetSelectWndInfo=function(e){var t=I.loadXML(e);u=parseInt(s.$XML(t).find("SelectWnd").eq(0).text(),10);var n=[];n.push(""),n.push(""+u+""),n.push(""),a.cbSelWnd&&a.cbSelWnd(I.loadXML(n.join("")))},e.ZoomInfoCallback=function(e){var t=f.findWndIndexByIndex(u);if(-1!=t){var s=p[t];if(t=f.findDeviceIndexByIP(s.szIP),-1!=t){var n=l[t];n.oProtocolInc.set3DZoom(n,s,e,{success:function(){},error:function(){}})}}},e.PluginEventHandler=function(e,t,s){Z("插件事件:PluginEventHandler iEventType:%s iParam1: %s, iParam2: %s",e,t,s),b==e||M==e?f.I_Stop(t):L==e?f.I_StopRecord(t):q==e&&f.I_StopVoiceTalk(),a.cbEvent&&a.cbEvent(e,t,s)},e.GetHttpInfo=function(e,t){Z("http响应返回:http状态:%s, http数据:%s",e,t),et.prototype.processCallback(e,t)};var Z=function(){if(a.bDebugMode){var e=k(arguments);d._alert(e)}},k=function(){for(var e=arguments[0],t=1;t";else for(var t=navigator.mimeTypes.length,s=0;t>s;s++)navigator.mimeTypes[s].type.toLowerCase()==a.szMimeTypes&&(e="");return e},E=function(){var e=c.HWP_GetLocalConfig();m=I.loadXML(e)},N=function(e){f.I_GetDeviceInfo(e.szIP,{success:function(t){e.szDeviceType=s.$XML(t).find("deviceType").eq(0).text()}}),f.I_GetAnalogChannelInfo(e.szIP,{success:function(t){e.iAnalogChannelNum=s.$XML(t).find("VideoInputChannel",!0).length}}),f.I_GetAudioInfo(e.szIP,{success:function(t){var n=s.$XML(t).find("audioCompressionType",!0);if(n.length>0){var r=s.$XML(n).eq(0).text(),o=0;"G.711ulaw"==r?o=1:"G.711alaw"==r?o=2:"G.726"==r&&(o=3),e.iAudioType=o}}})},B=function(e){var t=-1,s=-1,n=-1,r=null;if(O(e))r=F(e),t=r.iRtspPort,n=r.iDevicePort;else{for(var o=V(e),i=!1,a=0;ai;i++)"rtsp"===s.$XML(o).eq(i).find("protocol").eq(0).text().toLowerCase()&&(t=parseInt(s.$XML(o).eq(i).find("portNo").eq(0).text(),10)),"http"===s.$XML(o).eq(i).find("protocol").eq(0).text().toLowerCase()&&(n=parseInt(s.$XML(o).eq(i).find("portNo").eq(0).text(),10)),"dev_manage"===s.$XML(o).eq(i).find("protocol").eq(0).text().toLowerCase()&&(r=parseInt(s.$XML(o).eq(i).find("portNo").eq(0).text(),10))},error:function(){t=-1,n=-1,r=-1}}),{iRtspPort:t,iHttpPort:n,iDevicePort:r}},U=function(e){var t=-1,n=-1,r=-1;return e.oProtocolInc.getUPnPPortStatus(e,{async:!1,success:function(e){for(var o=s.$XML(e).find("portStatus",!0),i=0,a=o.length;a>i;i++)"rtsp"==s.$XML(o).eq(i).find("internalPort").eq(0).text().toLowerCase()&&(t=parseInt(s.$XML(o).eq(i).find("externalPort").eq(0).text(),10)),"http"==s.$XML(o).eq(i).find("internalPort").eq(0).text().toLowerCase()&&(n=parseInt(s.$XML(o).eq(i).find("externalPort").eq(0).text(),10)),"admin"==s.$XML(o).eq(i).find("internalPort").eq(0).text().toLowerCase()&&(r=parseInt(s.$XML(o).eq(i).find("externalPort").eq(0).text(),10))},error:function(){t=-1,n=-1,r=-1}}),{iRtspPort:t,iHttpPort:n,iDevicePort:r}},V=function(e){var t=[];return e.oProtocolInc.getNetworkBond(e,{async:!1,success:function(n){"true"==s.$XML(n).find("enabled").eq(0).text()?t.push({ipv4:s.$XML(n).find("ipAddress").eq(0).text(),ipv6:s.$XML(n).find("ipv6Address").eq(0).text()}):e.oProtocolInc.getNetworkInterface(e,{async:!1,success:function(e){for(var n=s.$XML(e).find("NetworkInterface",!0),r=0,o=n.length;o>r;r++){t.push({ipv4:s.$XML(e).find("ipAddress").eq(0).text(),ipv6:s.$XML(e).find("ipv6Address").eq(0).text()});break}},error:function(){}})},error:function(){e.oProtocolInc.getNetworkInterface(e,{success:function(e){for(var n=s.$XML(e).find("NetworkInterface",!0),r=0,o=n.length;o>r;r++){t.push({ipv4:s.$XML(e).find("ipAddress").eq(0).text(),ipv6:s.$XML(e).find("ipv6Address").eq(0).text()});break}},error:function(){}})}}),t},O=function(e){var t=!1;return e.oProtocolInc.getPPPoEStatus(e,{async:!1,success:function(e){t=s.$XML(e).find("ipAddress",!0).length>0?!0:s.$XML(e).find("ipv6Address",!0).length>0?!0:!1},error:function(){t=!1}}),t},j=function(e){e.oStreamCapa.bObtained||e.oProtocolInc instanceof tt&&(G==e.szDeviceType||X==e.szDeviceType||H==e.szDeviceType?e.oProtocolInc.getStreamChannels(e,{async:!1,success:function(t){e.oStreamCapa.bObtained=!0;for(var s=$(t).find("streamingTransport",!0).length,n=0;s>n;n++)if("shttp"==$(t).find("streamingTransport").eq(n).text().toLowerCase()){e.oStreamCapa.bObtained=!0,e.oStreamCapa.bSupportShttpPlay=!0,e.oStreamCapa.bSupportShttpPlayback=!0,e.oStreamCapa.bSupportShttpsPlay=!0,e.oStreamCapa.bSupportShttpsPlayback=!0,e.oStreamCapa.iIpChanBase=1;break}},error:function(){}}):e.oProtocolInc.getSDKCapa(e,{async:!1,success:function(t){e.oStreamCapa.bObtained=!0,e.oStreamCapa.bSupportShttpPlay="true"===s.$XML(t).find("isSupportHttpPlay").eq(0).text(),e.oStreamCapa.bSupportShttpPlayback="true"===s.$XML(t).find("isSupportHttpPlayback").eq(0).text(),e.oStreamCapa.bSupportShttpsPlay="true"===s.$XML(t).find("isSupportHttpsPlay").eq(0).text(),e.oStreamCapa.bSupportShttpsPlayback="true"===s.$XML(t).find("isSupportHttpsPlayback").eq(0).text(),e.oStreamCapa.bSupportShttpPlaybackTransCode="true"===s.$XML(t).find("isSupportHttpTransCodePlayback").eq(0).text(),e.oStreamCapa.bSupportShttpsPlaybackTransCode="true"===s.$XML(t).find("isSupportHttpsTransCodePlayback").eq(0).text(),s.$XML(t).find("ipChanBase",!0).length>0&&(e.oStreamCapa.iIpChanBase=parseInt(s.$XML(t).find("ipChanBase").eq(0).text(),10))},error:function(){e.oStreamCapa.bObtained=!0}}))},K=function(e){var t={TransFrameRate:"",TransResolution:"",TransBitrate:""};if(I.extend(t,e),""==t.TransFrameRate||""==t.TransResolution||""==t.TransBitrate)return"";var s=[];return s.push(""),s.push(""),s.push(""+t.TransFrameRate+""),s.push(""+t.TransResolution+""),s.push(""+t.TransBitrate+""),s.push(""),s.join("")};this.I_InitPlugin=function(e,t,s){n=e,r=t,I.extend(a,s)},this.I_InsertOBJECTPlugin=function(t){return W(t)||(a.szContainerID=t),null==document.getElementById(a.szContainerID)?-1:null!=document.getElementById(o)||0!=document.getElementsByName(o).length?-1:(document.getElementById(a.szContainerID).innerHTML=_(),c=I.browser().msie?document.getElementById(o):document.getElementsByName(i)[0],null==c&&null==c.object?-1:("object"==typeof e.attachEvent&&I.browser().msie&&(c.attachEvent("GetSelectWndInfo",GetSelectWndInfo),c.attachEvent("ZoomInfoCallback",ZoomInfoCallback),c.attachEvent("GetHttpInfo",GetHttpInfo),c.attachEvent("PluginEventHandler",PluginEventHandler)),E(),0))},this.I_WriteOBJECT_XHTML=function(){return document.writeln(_()),c=I.browser().msie?document.getElementById(o):document.getElementsByName(i)[0],null==c&&null==c.object?-1:(I.browser().msie&&(c.attachEvent("GetSelectWndInfo",GetSelectWndInfo),c.attachEvent("ZoomInfoCallback",ZoomInfoCallback),c.attachEvent("GetHttpInfo",GetHttpInfo),c.attachEvent("PluginEventHandler",PluginEventHandler)),E(),0)},this.I_OpenFileDlg=function(e){var t=c.HWP_OpenFileBrowser(e,"");if(null==t)return"";if(1==e){if(t.length>100)return-1}else if(t.length>130)return-1;return t},this.I_GetLocalCfg=function(){var e=c.HWP_GetLocalConfig(),t=[];return m=I.loadXML(e),t.push(""),t.push(""+s.$XML(m).find("ProtocolType").eq(0).text()+""),t.push(""+s.$XML(m).find("PackgeSize").eq(0).text()+""),t.push(""+s.$XML(m).find("PlayWndType").eq(0).text()+""),t.push(""+s.$XML(m).find("BuffNumberType").eq(0).text()+""),t.push(""+s.$XML(m).find("RecordPath").eq(0).text()+""),t.push(""+s.$XML(m).find("CapturePath").eq(0).text()+""),t.push(""+s.$XML(m).find("PlaybackFilePath").eq(0).text()+""),t.push(""+s.$XML(m).find("PlaybackPicPath").eq(0).text()+""),t.push(""+s.$XML(m).find("DownloadPath").eq(0).text()+""),t.push(""+s.$XML(m).find("IVSMode").eq(0).text()+""),t.push(""+s.$XML(m).find("CaptureFileFormat").eq(0).text()+""),t.push(""),I.loadXML(t.join(""))},this.I_SetLocalCfg=function(e){var t=I.loadXML(e),n=-1;return s.$XML(m).find("ProtocolType").eq(0).text(s.$XML(t).find("ProtocolType").eq(0).text()),s.$XML(m).find("PackgeSize").eq(0).text(s.$XML(t).find("PackgeSize").eq(0).text()),s.$XML(m).find("PlayWndType").eq(0).text(s.$XML(t).find("PlayWndType").eq(0).text()),s.$XML(m).find("BuffNumberType").eq(0).text(s.$XML(t).find("BuffNumberType").eq(0).text()),s.$XML(m).find("RecordPath").eq(0).text(s.$XML(t).find("RecordPath").eq(0).text()),s.$XML(m).find("CapturePath").eq(0).text(s.$XML(t).find("CapturePath").eq(0).text()),s.$XML(m).find("PlaybackFilePath").eq(0).text(s.$XML(t).find("PlaybackFilePath").eq(0).text()),s.$XML(m).find("PlaybackPicPath").eq(0).text(s.$XML(t).find("PlaybackPicPath").eq(0).text()),s.$XML(m).find("DownloadPath").eq(0).text(s.$XML(t).find("DownloadPath").eq(0).text()),s.$XML(m).find("IVSMode").eq(0).text(s.$XML(t).find("IVSMode").eq(0).text()),s.$XML(m).find("CaptureFileFormat").eq(0).text(s.$XML(t).find("CaptureFileFormat").eq(0).text()),n=c.HWP_SetLocalConfig(I.toXMLStr(m)),n?0:-1};var Y=function(e,t,s,n,r,o,i){var a={protocol:t,success:null,error:null};I.extend(a,i),I.extend(a,{success:function(a){var c=new J;c.szIP=e,2==t?(c.szHttpProtocol="https://",c.iHttpsPort=s):(c.szHttpProtocol="http://",c.iHttpPort=s),c.iCGIPort=s,c.szAuth=n,c.iDeviceProtocol=r,c.oProtocolInc=o,l.push(c),Z("使用%s协议登录成功",r),N(c),i.success&&i.success(a)},error:function(e,t){i.error&&i.error(e,t)}}),o.login(e,s,n,a)};this.I_Login=function(e,t,s,n,r,o){var i=this.findDeviceIndexByIP(e);if(-1!=i)return Z("设备已经登录过"),-1;var a=P,c=C;W(o.cgi)||(C==o.cgi?(a=P,c=C):(a=h,c=S));var u="";if(C==c){u=I.Base64.encode(":"+n+":"+r);var l={success:null,error:null};I.extend(l,o),I.extend(l,{error:function(i,l){u=I.Base64.encode(n+":"+r),c=C,a=P;var p={success:null,error:null};I.extend(p,o),I.extend(p,{error:function(){if(!W(o.cgi))return void(o.error&&o.error(i,l));u=I.Base64.encode(n+":"+r),c=S,a=h;var p={success:null,error:null};I.extend(p,o),I.extend(p,{error:function(e,t){o.error&&o.error(e,t)}}),Y(e,t,s,u,c,a,p)}}),Y(e,t,s,u,c,a,p)}}),Y(e,t,s,u,c,a,l)}else{u=I.Base64.encode(n+":"+r),c=S,a=h;var l={success:null,error:null};I.extend(l,o),I.extend(l,{error:function(e,t){o.error&&o.error(e,t)}}),Y(e,t,s,u,c,a,l)}},this.I_Logout=function(e){var t=this.findDeviceIndexByIP(e);return-1!=t?(l.splice(t,1),0):-1},this.I_GetAudioInfo=function(e,t){var s=this.findDeviceIndexByIP(e);if(-1!=s){var n=l[s],r={success:null,error:null};I.extend(r,t),n.oProtocolInc.getAudioInfo(n,r)}},this.I_GetDeviceInfo=function(e,t){var s=this.findDeviceIndexByIP(e);if(-1!=s){var n=l[s],r={success:null,error:null};I.extend(r,t),n.oProtocolInc.getDeviceInfo(n,r)}},this.I_GetAnalogChannelInfo=function(e,t){var s=this.findDeviceIndexByIP(e);if(-1!=s){var n=l[s],r={success:null,error:null};I.extend(r,t),n.oProtocolInc.getAnalogChannelInfo(n,r)}},this.I_GetDigitalChannelInfo=function(e,t){var s=this.findDeviceIndexByIP(e);if(-1!=s){var n=l[s],r={success:null,error:null};I.extend(r,t),n.oProtocolInc.getDigitalChannelInfo(n,r)}},this.I_GetZeroChannelInfo=function(e,t){var s=this.findDeviceIndexByIP(e);if(-1!=s){var n=l[s],r={success:null,error:null};I.extend(r,t),n.oProtocolInc.getZeroChannelInfo(n,r)}},this.I_StartRealPlay=function(e,t){var n=this.findDeviceIndexByIP(e),r=-1,o="",i="",a=-1,c=0,d=0,P=!1,h={iWndIndex:u,iStreamType:1,iChannelID:1,bZeroChannel:!1};if(I.extend(h,t),-1!=n){j(l[n]);var f=l[n],C=parseInt(s.$XML(m).find("ProtocolType").eq(0).text(),10);if(C==R&&f.oStreamCapa.bSupportShttpPlay?(Z("SHTTP RealPlay"),o=f.oProtocolInc.CGI.startShttpRealPlay,i="http://",d=h.iStreamType-1,c=h.iChannelID<=f.iAnalogChannelNum?h.iChannelID:f.oStreamCapa.iIpChanBase+parseInt(h.iChannelID,10)-f.iAnalogChannelNum-1,P=!0,W(h.iPort)?"https://"==f.szHttpProtocol?(-1==f.iHttpPort&&(f.iHttpPort=B(f).iHttpPort),a=f.iHttpPort):a=f.iCGIPort:(f.iHttpPort=h.iPort,a=h.iPort)):(Z("RTSP RealPlay"),o=f.oProtocolInc.CGI.startRealPlay,i="rtsp://",d=h.iStreamType,c=h.iChannelID,W(h.iPort)||(f.iRtspPort=h.iPort),-1==f.iRtspPort&&(f.iRtspPort=B(f).iRtspPort),a=f.iRtspPort),-1==a)return Z("获取端口号失败"),r;if(I.extend(h,{urlProtocol:i,cgi:o,iPort:a,iStreamType:d,iChannelID:c}),n=this.findWndIndexByIndex(h.iWndIndex),-1==n&&(r=f.oProtocolInc.startRealPlay(f,h)),-1==r)f.iRtspPort=-1;else{n=this.findWndIndexByIndex(h.iWndIndex);var S=p[n];S.bShttpIPChannel=P}}return r},this.I_Stop=function(e){e=W(e)?u:e;var t=this.findWndIndexByIndex(e),s=-1;if(-1!=t){var n=p[t];n.bRecord&&c.HWP_StopSave(n.iIndex),n.bSound&&c.HWP_CloseSound(),n.bEZoom&&c.HWP_DisableZoom(n.iIndex),s=c.HWP_Stop(e),0==s&&p.splice(t,1)}return s},this.I_OpenSound=function(e){e=W(e)?u:e;var t=this.findWndIndexByIndex(e),s=-1;if(-1!=t){var n=p[t];n.bSound||(s=c.HWP_OpenSound(e),0==s&&(n.bSound=!0))}return s},this.I_CloseSound=function(e){e=W(e)?u:e;var t=this.findWndIndexByIndex(e),s=-1;if(-1!=t){var n=p[t];n.bSound&&(s=c.HWP_CloseSound(),0==s&&(n.bSound=!1))}return s},this.I_SetVolume=function(e,t){t=W(t)?u:t;var s=this.findWndIndexByIndex(t),n=-1;return-1!=s&&(n=c.HWP_SetVolume(t,e)),n},this.I_CapturePic=function(e,t){t=W(t)?u:t;var s=this.findWndIndexByIndex(t),n=-1;return-1!=s&&(n=c.HWP_CapturePicture(t,e)),n},this.I_StartRecord=function(e,t){t=W(t)?u:t;var s=this.findWndIndexByIndex(t),n=-1;if(-1!=s){var r=p[s];r.bRecord||(n=c.HWP_StartSave(t,e),0==n&&(r.bRecord=!0))}return n},this.I_StopRecord=function(e){e=W(e)?u:e;var t=this.findWndIndexByIndex(e),s=-1;if(-1!=t){var n=p[t];n.bRecord&&(s=c.HWP_StopSave(e),0==s&&(n.bRecord=!1))}return s},this.I_StartVoiceTalk=function(e,t){if(isNaN(parseInt(t,10)))return-1;var s=this.findDeviceIndexByIP(e),n=-1;if(-1!=s){var r=l[s];r.bVoiceTalk||(n=r.oProtocolInc.startVoiceTalk(r,t),0==n&&(l[s].bVoiceTalk=!0))}return n},this.I_StopVoiceTalk=function(){for(var e=c.HWP_StopVoiceTalk(),t=0,s=l.length;s>t;t++)if(l[t].bVoiceTalk){l[t].bVoiceTalk=!1;break}return e},this.I_PTZControl=function(e,t,s){var n={iWndIndex:u,iPTZIndex:e,iPTZSpeed:4};I.extend(n,s),I.extend(n,{async:!1});var r=this.findWndIndexByIndex(n.iWndIndex);if(-1!=r){var o=p[r];if(r=this.findDeviceIndexByIP(o.szIP),-1!=r){var i=l[r];9==e?i.oProtocolInc.ptzAutoControl(i,t,o,n):i.oProtocolInc.ptzControl(i,t,o,n)}}},this.I_EnableEZoom=function(e){e=W(e)?u:e;var t=this.findWndIndexByIndex(e),s=-1;if(-1!=t){var n=p[t];n.bEZoom||(s=c.HWP_EnableZoom(e,0),0==s&&(n.bEZoom=!0))}return s},this.I_DisableEZoom=function(e){e=W(e)?u:e;var t=this.findWndIndexByIndex(e),s=-1;if(-1!=t){var n=p[t];if(n.bEZoom)return c.HWP_DisableZoom(e),n.bEZoom=!1,0}return s},this.I_Enable3DZoom=function(e){e=W(e)?u:e;var t=this.findWndIndexByIndex(e),s=-1;if(-1!=t){var n=p[t];n.b3DZoom||(s=c.HWP_EnableZoom(e,1),0==s&&(n.b3DZoom=!0))}return s},this.I_Disable3DZoom=function(e){e=W(e)?u:e;var t=this.findWndIndexByIndex(e),s=-1;if(-1!=t){var n=p[t];if(n.b3DZoom)return c.HWP_DisableZoom(e),n.b3DZoom=!1,0}return s},this.I_FullScreen=function(e){c.HWP_FullScreenDisplay(e)},this.I_SetPreset=function(e,t){var s={iWndIndex:u,iPresetID:e};I.extend(s,t);var n=this.findWndIndexByIndex(s.iWndIndex);if(-1!=n){var r=p[n];if(n=this.findDeviceIndexByIP(r.szIP),-1!=n){var o=l[n];o.oProtocolInc.setPreset(o,r,s)}}},this.I_GoPreset=function(e,t){var s={iWndIndex:u,iPresetID:e};I.extend(s,t);var n=this.findWndIndexByIndex(s.iWndIndex);if(-1!=n){var r=p[n];if(n=this.findDeviceIndexByIP(r.szIP),-1!=n){var o=l[n];o.oProtocolInc.goPreset(o,r,s)}}},this.I_RecordSearch=function(e,t,s,n,r){var o=this.findDeviceIndexByIP(e);if(-1!=o){var i=l[o],a={iChannelID:t,szStartTime:s,szEndTime:n,iSearchPos:0,success:null,error:null};I.extend(a,r),i.oProtocolInc.recordSearch(i,a)}},this.I_StartPlayback=function(e,t){var n=this.findDeviceIndexByIP(e),r=-1,o="",i="",a=-1,c=1,p=I.dateFormat(new Date,"yyyy-MM-dd"),d={iWndIndex:u,iChannelID:1,szStartTime:p+" 00:00:00",szEndTime:p+" 23:59:59"};if(I.extend(d,t),-1!=n){j(l[n]);var P=l[n],h=parseInt(s.$XML(m).find("ProtocolType").eq(0).text(),10);if(h==R&&P.oStreamCapa.bSupportShttpPlay?(o=W(d.oTransCodeParam)?P.oProtocolInc.CGI.startShttpPlayback:P.oProtocolInc.CGI.startTransCodePlayback,i="http://",c=d.iChannelID<=P.iAnalogChannelNum?d.iChannelID:P.oStreamCapa.iIpChanBase+parseInt(d.iChannelID,10)-P.iAnalogChannelNum-1,W(d.iPort)?"https://"==P.szHttpProtocol?(-1==P.iHttpPort&&(P.iHttpPort=B(P).iHttpPort),a=P.iHttpPort):a=P.iCGIPort:(P.iHttpPort=d.iPort,a=d.iPort)):(o=P.oProtocolInc.CGI.startPlayback,i="rtsp://",c=100*d.iChannelID+1,W(d.iPort)||(P.iRtspPort=d.iPort),-1==P.iRtspPort&&(P.iRtspPort=B(P).iRtspPort),a=P.iRtspPort),-1==a)return Z("获取端口号失败"),r;I.extend(d,{urlProtocol:i,cgi:o,iPort:a,iChannelID:c}),n=this.findWndIndexByIndex(d.iWndIndex),-1==n&&(d.szStartTime=d.szStartTime.replace(/[-:]/g,"").replace(" ","T")+"Z",d.szEndTime=d.szEndTime.replace(/[-:]/g,"").replace(" ","T")+"Z",r=P.oProtocolInc.startPlayback(P,d)),-1==r&&(P.iRtspPort=-1)}return r},this.I_ReversePlayback=function(e,t){var n=this.findDeviceIndexByIP(e),r=-1,o="",i="",a=-1,c=-1,p=I.dateFormat(new Date,"yyyy-MM-dd"),d={iWndIndex:u,iChannelID:1,bZeroChannel:!1,szStartTime:p+" 00:00:00",szEndTime:p+" 23:59:59"};if(I.extend(d,t),-1!=n){j(l[n]);var P=l[n],h=parseInt(s.$XML(m).find("ProtocolType").eq(0).text(),10);if(h==R&&P.oStreamCapa.bSupportShttpPlay?(o=P.oProtocolInc.CGI.startShttpReversePlayback,i="http://",c=d.iChannelID<=P.iAnalogChannelNum?d.iChannelID:P.oStreamCapa.iIpChanBase+parseInt(d.iChannelID,10)-P.iAnalogChannelNum-1,W(d.iPort)?"https://"==P.szHttpProtocol?(-1==P.iHttpPort&&(P.iHttpPort=B(P).iHttpPort),a=P.iHttpPort):a=P.iCGIPort:(P.iHttpPort=d.iPort,a=d.iPort)):(o=P.oProtocolInc.CGI.startPlayback,i="rtsp://",c=100*d.iChannelID+1,W(d.iPort)||(P.iRtspPort=d.iPort),-1==P.iRtspPort&&(P.iRtspPort=B(P).iRtspPort),a=P.iRtspPort),-1==a)return Z("获取端口号失败"),r;I.extend(d,{urlProtocol:i,cgi:o,iPort:a,iChannelID:c}),n=this.findWndIndexByIndex(d.iWndIndex),-1==n&&(d.szStartTime=d.szStartTime.replace(/[-:]/g,"").replace(" ","T")+"Z",d.szEndTime=d.szEndTime.replace(/[-:]/g,"").replace(" ","T")+"Z",r=P.oProtocolInc.reversePlayback(P,d))}return-1==r&&(P.iRtspPort=-1),r},this.I_Frame=function(e){e=W(e)?u:e;var t=this.findWndIndexByIndex(e),s=-1;if(-1!=t){var n=p[t],r=n.iPlayStatus;(r==x||r==z)&&(s=c.HWP_FrameForward(e),0==s&&(n.iPlayStatus=z))}return s},this.I_Pause=function(e){e=W(e)?u:e;var t=this.findWndIndexByIndex(e),s=-1;if(-1!=t){var n=p[t],r=n.iPlayStatus;r==x?(s=c.HWP_Pause(e),0==s&&(n.iPlayStatus=T)):r==D&&(s=c.HWP_Pause(e),0==s&&(n.iPlayStatus=A))}return s},this.I_Resume=function(e){e=W(e)?u:e;var t=this.findWndIndexByIndex(e),s=-1;if(-1!=t){var n=p[t],r=n.iPlayStatus;r==T||r==z?(s=c.HWP_Resume(e),0==s&&(n.iPlayStatus=x)):r==A&&(s=c.HWP_Resume(e),0==s&&(n.iPlayStatus=D))}return s},this.I_PlaySlow=function(e){e=W(e)?u:e;var t=this.findWndIndexByIndex(e),s=-1;if(-1!=t){var n=p[t];n.iPlayStatus==x&&(s=c.HWP_Slow(e))}return s},this.I_PlayFast=function(e){e=W(e)?u:e;var t=this.findWndIndexByIndex(e),s=-1;if(-1!=t){var n=p[t];n.iPlayStatus==x&&(s=c.HWP_Fast(e))}return s},this.I_GetOSDTime=function(e){e=W(e)?u:e;var t=this.findWndIndexByIndex(e),s=-1;if(-1!=t){var n=c.HWP_GetOSDTime(e);return I.dateFormat(new Date(1e3*n),"yyyy-MM-dd hh:mm:ss")}return s},this.I_StartDownloadRecord=function(e,t,s){var n=this.findDeviceIndexByIP(e),r=-1;if(-1!=n){var o=l[n],i={szPlaybackURI:t,szFileName:s};r=o.oProtocolInc.startDownloadRecord(o,i)}return r},this.I_GetDownloadStatus=function(e){return c.HWP_GetDownloadStatus(e)},this.I_GetDownloadProgress=function(e){return c.HWP_GetDownloadProgress(e)},this.I_StopDownloadRecord=function(e){return c.HWP_StopDownload(e)},this.I_ExportDeviceConfig=function(e){var t=this.findDeviceIndexByIP(e);if(-1!=t){var s=l[t];return s.oProtocolInc.exportDeviceConfig(s)}},this.I_ImportDeviceConfig=function(e,t){var s=this.findDeviceIndexByIP(e),n=-1;if(-1!=s){var r=l[s],o={szFileName:t};n=r.oProtocolInc.importDeviceConfig(r,o)}return n},this.I_RestoreDefault=function(e,t,s){var n={success:null,error:null};I.extend(n,s);var r=this.findDeviceIndexByIP(e);if(-1!=r){var o=l[r];o.oProtocolInc.restore(o,t,n)}},this.I_Restart=function(e,t){var s=this.findDeviceIndexByIP(e),n={success:null,error:null};if(I.extend(n,t),-1!=s){var r=l[s];r.oProtocolInc.restart(r,n)}},this.I_Reconnect=function(e,t){var s=this.findDeviceIndexByIP(e),n={success:null,error:null};if(I.extend(n,t),-1!=s){var r=l[s];r.oProtocolInc.login(r.szIP,r.iCGIPort,r.szAuth,n)}},this.I_StartUpgrade=function(e,t){var s=this.findDeviceIndexByIP(e),n=-1;if(-1!=s){var r=l[s],o={szFileName:t};n=r.oProtocolInc.startUpgrade(r,o)}return n},this.I_UpgradeStatus=function(){return c.HWP_UpgradeStatus()},this.I_UpgradeProgress=function(){return c.HWP_UpgradeProgress()},this.I_StopUpgrade=function(){return c.HWP_StopUpgrade()},this.I_CheckPluginInstall=function(){var e=!1;if(I.browser().msie)try{{new ActiveXObject("WebVideoActiveX.WebVideoActiveXCtrl.1")}e=!0}catch(t){}else for(var s=0,n=navigator.mimeTypes.length;n>s;s++)if("application/hwp-webvideo-plugin"==navigator.mimeTypes[s].type.toLowerCase()){e=!0;break}return e?0:-1},this.I_CheckPluginVersion=function(){return c.HWP_CheckPluginUpdate(w)?-1:0},this.I_RemoteConfig=function(e,t){var s=this.findDeviceIndexByIP(e),n=-1,r=-1,o={iLan:0,iDevicePort:-1,iType:0};if(I.extend(o,t),-1!=s){var i=l[s];if(-1==o.iDevicePort)if(-1==i.iDevicePort){if(i.iDevicePort=B(i).iDevicePort,r=i.iDevicePort,-1==r)return n}else r=i.iDevicePort;else r=o.iDevicePort;if(":"==I.Base64.decode(i.szAuth)[0])var a=I.Base64.decode(i.szAuth).split(":")[1],u=I.Base64.decode(i.szAuth).split(":")[2];else var a=I.Base64.decode(i.szAuth).split(":")[0],u=I.Base64.decode(i.szAuth).split(":")[1];var p=""+o.iType+""+o.iLan+""+e+""+r+""+a+""+I.Base64.encode(u)+"";return c.HWP_ShowRemConfig(p)}return n},this.I_ChangeWndNum=function(e){return isNaN(parseInt(e,10))?-1:void c.HWP_ArrangeWindow(e)},this.I_GetLastError=function(){return c.HWP_GetLastError()},this.I_GetWindowStatus=function(e){if(W(e)){var t=[];return I.extend(t,p),t}var s=this.findWndIndexByIndex(e);return-1!=s?p[s]:null},this.I_GetIPInfoByMode=function(e,t,s,n){return c.HWP_GetIpInfoByMode(e,t,s,n)},this.findDeviceIndexByIP=function(e){for(var t=0;t"),n.push(""+I.escape(s.$XML(e).find("deviceName").eq(0).text())+""),n.push(""+s.$XML(e).find("deviceID").eq(0).text()+""),n.push(""+s.$XML(e).find("deviceType").eq(0).text()+""),n.push(""+s.$XML(e).find("model").eq(0).text()+""),n.push(""+s.$XML(e).find("serialNumber").eq(0).text()+""),n.push(""+s.$XML(e).find("macAddress").eq(0).text()+""),n.push(""+s.$XML(e).find("firmwareVersion").eq(0).text()+""),n.push(""+s.$XML(e).find("firmwareReleasedDate").eq(0).text()+""),n.push(""+s.$XML(e).find("encoderVersion").eq(0).text()+""),n.push(""+s.$XML(e).find("encoderReleasedDate").eq(0).text()+""),n.push(""),e=I.loadXML(n.join("")),t.success&&t.success(e)},error:function(e,s){t.error&&t.error(e,s)}}),r.setRequestParam(o),r.submitRequest()},tt.prototype.getAnalogChannelInfo=function(e,t){var n=k(this.CGI.getAnalogChannelInfo,e.szHttpProtocol,e.szIP,e.iCGIPort),r=new et,o={type:"GET",url:n,auth:e.szAuth,success:null,error:null};I.extend(o,t),I.extend(o,{success:function(e){var n=[]; 2 | n.push("");for(var r=s.$XML(e).find("VideoInputChannel",!0),o=0,i=r.length;i>o;o++){var a=r[o];n.push(""),n.push(""+s.$XML(a).find("id").eq(0).text()+""),n.push(""+s.$XML(a).find("inputPort").eq(0).text()+""),n.push(""+I.escape(s.$XML(a).find("name").eq(0).text())+""),n.push(""+s.$XML(a).find("videoFormat").eq(0).text()+""),n.push("")}n.push(""),e=I.loadXML(n.join("")),t.success&&t.success(e)},error:function(e,s){t.error&&t.error(e,s)}}),r.setRequestParam(o),r.submitRequest()},tt.prototype.getDigitalChannelInfo=function(e,t){var n=k(this.CGI.getDigitalChannelInfo,e.szHttpProtocol,e.szIP,e.iCGIPort),r=new et,o={type:"GET",url:n,auth:e.szAuth,success:null,error:null};I.extend(o,t),I.extend(o,{success:function(e){var n=[];n.push("");for(var r=s.$XML(e).find("InputProxyChannelStatus",!0),o=0,i=r.length;i>o;o++){var a=r[o];n.push(""),n.push(""+s.$XML(a).find("id").eq(0).text()+""),n.push(""),n.push(""+s.$XML(a).find("proxyProtocol").eq(0).text()+""),n.push(""+s.$XML(a).find("addressingFormatType").eq(0).text()+""),n.push(""+s.$XML(a).find("ipAddress").eq(0).text()+""),n.push(""+s.$XML(a).find("managePortNo").eq(0).text()+""),n.push(""+s.$XML(a).find("srcInputPort").eq(0).text()+""),n.push(""+I.escape(s.$XML(a).find("userName").eq(0).text())+""),n.push(""+s.$XML(a).find("streamType").eq(0).text()+""),n.push(""+s.$XML(a).find("online").eq(0).text()+""),n.push(""),n.push("")}n.push(""),e=I.loadXML(n.join("")),t.success&&t.success(e)},error:function(e,s){t.error&&t.error(e,s)}}),r.setRequestParam(o),r.submitRequest()},tt.prototype.getZeroChannelInfo=function(e,t){var s=k(this.CGI.getZeroChannelInfo,e.szHttpProtocol,e.szIP,e.iCGIPort),n=new et,r={type:"GET",url:s,auth:e.szAuth,success:null,error:null};I.extend(r,t),I.extend(r,{success:function(e){t.success&&t.success(e)},error:function(e,s){t.error&&t.error(e,s)}}),n.setRequestParam(r),n.submitRequest()},tt.prototype.getStreamChannels=function(e,t){if(0!=e.iAnalogChannelNum)var s=k(this.CGI.getStreamChannels.analog,e.szHttpProtocol,e.szIP,e.iCGIPort);else var s=k(this.CGI.getStreamChannels.digital,e.szHttpProtocol,e.szIP,e.iCGIPort);var n=new et,r={type:"GET",url:s,auth:e.szAuth,success:null,error:null};I.extend(r,t),I.extend(r,{success:function(e){t.success&&t.success(e)},error:function(e,s){t.error&&t.error(e,s)}}),n.setRequestParam(r),n.submitRequest()},tt.prototype.getPPPoEStatus=function(e,t){var s=k(this.CGI.getPPPoEStatus,e.szHttpProtocol,e.szIP,e.iCGIPort),n=new et,r={type:"GET",url:s,auth:e.szAuth,success:null,error:null};I.extend(r,t),I.extend(r,{success:function(e){t.success&&t.success(e)},error:function(e,s){t.error&&t.error(e,s)}}),n.setRequestParam(r),n.submitRequest()},tt.prototype.getUPnPPortStatus=function(e,t){var s=k(this.CGI.getUPnPPortStatus,e.szHttpProtocol,e.szIP,e.iCGIPort),n=new et,r={type:"GET",url:s,auth:e.szAuth,success:null,error:null};I.extend(r,t),I.extend(r,{success:function(e){t.success&&t.success(e)},error:function(e,s){t.error&&t.error(e,s)}}),n.setRequestParam(r),n.submitRequest()},tt.prototype.getNetworkBond=function(e,t){var s=k(this.CGI.getNetworkBond,e.szHttpProtocol,e.szIP,e.iCGIPort),n=new et,r={type:"GET",url:s,auth:e.szAuth,success:null,error:null};I.extend(r,t),I.extend(r,{success:function(e){t.success&&t.success(e)},error:function(e,s){t.error&&t.error(e,s)}}),n.setRequestParam(r),n.submitRequest()},tt.prototype.getNetworkInterface=function(e,t){var s=k(this.CGI.getNetworkInterface,e.szHttpProtocol,e.szIP,e.iCGIPort),n=new et,r={type:"GET",url:s,auth:e.szAuth,success:null,error:null};I.extend(r,t),I.extend(r,{success:function(e){t.success&&t.success(e)},error:function(e,s){t.error&&t.error(e,s)}}),n.setRequestParam(r),n.submitRequest()},tt.prototype.getPortInfo=function(e,t){var s=k(this.CGI.getPortInfo,e.szHttpProtocol,e.szIP,e.iCGIPort),n=new et,r={type:"GET",url:s,auth:e.szAuth,success:null,error:null};I.extend(r,t),I.extend(r,{success:function(e){t.success&&t.success(e)},error:function(e,s){t.error&&t.error(e,s)}}),n.setRequestParam(r),n.submitRequest()},tt.prototype.startRealPlay=function(e,t){var s=100*t.iChannelID+t.iStreamType,n="";n=t.bZeroChannel?k(t.cgi.zeroChannels,t.urlProtocol,e.szIP,t.iPort,s):k(t.cgi.channels,t.urlProtocol,e.szIP,t.iPort,s);var r=c.HWP_Play(n,e.szAuth,t.iWndIndex,"","");if(0==r){var o=new Q;o.iIndex=t.iWndIndex,o.szIP=e.szIP,o.iChannelID=t.iChannelID,o.iPlayStatus=v,p.push(o)}return r},tt.prototype.startVoiceTalk=function(e,t){var s=k(this.CGI.startVoiceTalk.open,e.szHttpProtocol,e.szIP,e.iCGIPort,t),n=k(this.CGI.startVoiceTalk.close,e.szHttpProtocol,e.szIP,e.iCGIPort,t),r=k(this.CGI.startVoiceTalk.audioData,e.szHttpProtocol,e.szIP,e.iCGIPort,t),o=c.HWP_StartVoiceTalk(s,n,r,e.szAuth,e.iAudioType);return o},tt.prototype.ptzAutoControl=function(e,t,s,n){var r=s.iChannelID,o="",i="";if(n.iPTZSpeed=n.iPTZSpeed<7?15*n.iPTZSpeed:100,t&&(n.iPTZSpeed=0),e.szDeviceType!=X)o=r<=e.iAnalogChannelNum?k(this.CGI.ptzAutoControl.analog,e.szHttpProtocol,e.szIP,e.iCGIPort,s.iChannelID):s.bShttpIPChannel?k(this.CGI.ptzAutoControl.digital,e.szHttpProtocol,e.szIP,e.iCGIPort,s.iChannelID-e.oStreamCapa.iIpChanBase+1+e.iAnalogChannelNum):k(this.CGI.ptzAutoControl.digital,e.szHttpProtocol,e.szIP,e.iCGIPort,s.iChannelID),i=""+n.iPTZSpeed+"";else{var a=99;t&&(a=96),o=k(this.CGI.ptzAutoControl.ipdome,e.szHttpProtocol,e.szIP,e.iCGIPort,s.iChannelID,a)}var c=new et,u={type:"PUT",url:o,async:!1,auth:e.szAuth,data:i,success:null,error:null},l=this;I.extend(u,n),I.extend(u,{success:function(e){s.bPTZAuto=!s.bPTZAuto,n.success&&n.success(e)},error:function(t,r){if(G==e.szDeviceType||H==e.szDeviceType){o=s.bShttpIPChannel?k(l.CGI.ptzControl.analog,e.szHttpProtocol,e.szIP,e.iCGIPort,s.iChannelID-e.oStreamCapa.iIpChanBase+1+e.iAnalogChannelNum):k(l.CGI.ptzControl.analog,e.szHttpProtocol,e.szIP,e.iCGIPort,s.iChannelID),i=""+n.iPTZSpeed+"0";var a=new et,c={type:"PUT",url:o,async:!1,auth:e.szAuth,data:i,success:null,error:null};I.extend(c,n),a.setRequestParam(c),a.submitRequest()}else n.error&&n.error(t,r)}}),c.setRequestParam(u),c.submitRequest()},tt.prototype.ptzControl=function(e,t,s,n){var r=s.iChannelID,o="";s.bPTZAuto&&this.ptzAutoControl(e,!0,s,{iPTZSpeed:0}),n.iPTZSpeed=t?0:n.iPTZSpeed<7?15*n.iPTZSpeed:100;var i=[{},{pan:0,tilt:n.iPTZSpeed},{pan:0,tilt:-n.iPTZSpeed},{pan:-n.iPTZSpeed,tilt:0},{pan:n.iPTZSpeed,tilt:0},{pan:-n.iPTZSpeed,tilt:n.iPTZSpeed},{pan:-n.iPTZSpeed,tilt:-n.iPTZSpeed},{pan:n.iPTZSpeed,tilt:n.iPTZSpeed},{pan:n.iPTZSpeed,tilt:-n.iPTZSpeed},{},{speed:n.iPTZSpeed},{speed:-n.iPTZSpeed},{speed:n.iPTZSpeed},{speed:-n.iPTZSpeed},{speed:n.iPTZSpeed},{speed:-n.iPTZSpeed}],a="",c={};switch(n.iPTZIndex){case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:c=this.CGI.ptzControl,a=""+i[n.iPTZIndex].pan+""+i[n.iPTZIndex].tilt+"";break;case 10:case 11:c=this.CGI.ptzControl,a=""+i[n.iPTZIndex].speed+"";break;case 12:case 13:c=this.CGI.ptzFocus,a=""+i[n.iPTZIndex].speed+"";break;case 14:case 15:c=this.CGI.ptzIris,a=""+i[n.iPTZIndex].speed+"";break;default:return void(W(n.error)&&n.error())}o=c!=this.CGI.ptzFocus&&c!=this.CGI.ptzIris||e.szDeviceType!=G&&e.szDeviceType!=X&&e.szDeviceType!=H?r<=e.iAnalogChannelNum?k(c.analog,e.szHttpProtocol,e.szIP,e.iCGIPort,s.iChannelID):s.bShttpIPChannel?k(c.digital,e.szHttpProtocol,e.szIP,e.iCGIPort,s.iChannelID-e.oStreamCapa.iIpChanBase+1+e.iAnalogChannelNum):k(c.digital,e.szHttpProtocol,e.szIP,e.iCGIPort,s.iChannelID):k(c.ipc,e.szHttpProtocol,e.szIP,e.iCGIPort,s.iChannelID);var u=new et,l={type:"PUT",url:o,async:!1,auth:e.szAuth,data:a,success:null,error:null};I.extend(l,n),I.extend(l,{success:function(e){n.success&&n.success(e)},error:function(e,t){n.error&&n.error(e,t)}}),u.setRequestParam(l),u.submitRequest()},tt.prototype.setPreset=function(e,t,s){var n=t.iChannelID,r="",o="";r=n<=e.iAnalogChannelNum?k(this.CGI.setPreset.analog,e.szHttpProtocol,e.szIP,e.iCGIPort,t.iChannelID,s.iPresetID):t.bShttpIPChannel?k(this.CGI.setPreset.digital,e.szHttpProtocol,e.szIP,e.iCGIPort,t.iChannelID-e.oStreamCapa.iIpChanBase+1+e.iAnalogChannelNum,s.iPresetID):k(this.CGI.setPreset.digital,e.szHttpProtocol,e.szIP,e.iCGIPort,t.iChannelID,s.iPresetID),o="",o+="",o+=""+s.iPresetID+"",e.szDeviceType!=X&&(o+="Preset"+s.iPresetID+""),o+="";var i=new et,a={type:"PUT",url:r,auth:e.szAuth,data:o,success:null,error:null};I.extend(a,s),I.extend(a,{success:function(e){s.success&&s.success(e)},error:function(e,t){s.error&&s.error(e,t)}}),i.setRequestParam(a),i.submitRequest()},tt.prototype.goPreset=function(e,t,s){var n=t.iChannelID,r="";r=n<=e.iAnalogChannelNum?k(this.CGI.goPreset.analog,e.szHttpProtocol,e.szIP,e.iCGIPort,t.iChannelID,s.iPresetID):t.bShttpIPChannel?k(this.CGI.goPreset.digital,e.szHttpProtocol,e.szIP,e.iCGIPort,t.iChannelID-e.oStreamCapa.iIpChanBase+1+e.iAnalogChannelNum,s.iPresetID):k(this.CGI.goPreset.digital,e.szHttpProtocol,e.szIP,e.iCGIPort,t.iChannelID,s.iPresetID);var o=new et,i={type:"PUT",url:r,auth:e.szAuth,success:null,error:null};I.extend(i,s),I.extend(i,{success:function(e){s.success&&s.success(e)},error:function(e,t){s.error&&s.error(e,t)}}),o.setRequestParam(i),o.submitRequest()},tt.prototype.recordSearch=function(e,n){var r="",o="",i=n.iChannelID,a=n.szStartTime.replace(" ","T")+"Z",c=n.szEndTime.replace(" ","T")+"Z";r=k(this.CGI.recordSearch,e.szHttpProtocol,e.szIP,e.iCGIPort),o=""+new t+""+(100*i+1)+""+a+""+c+"40"+n.iSearchPos+"//metadata.ISAPI.org/VideoMotion";var u=new et,l={type:"POST",url:r,auth:e.szAuth,data:o,success:null,error:null};I.extend(l,n),I.extend(l,{success:function(e){var t=[];t.push(""),t.push(""+s.$XML(e).find("responseStatus").eq(0).text()+""),t.push(""+s.$XML(e).find("responseStatusStrg").eq(0).text()+""),t.push(""+s.$XML(e).find("numOfMatches").eq(0).text()+""),t.push("");for(var r=s.$XML(e).find("searchMatchItem",!0),o=0,i=r.length;i>o;o++){var a=r[o];t.push(""),t.push(""+s.$XML(a).find("trackID").eq(0).text()+""),t.push(""+s.$XML(a).find("startTime").eq(0).text()+""),t.push(""+s.$XML(a).find("endTime").eq(0).text()+""),t.push(""+I.escape(s.$XML(a).find("playbackURI").eq(0).text())+""),t.push(""+s.$XML(a).find("metadataDescriptor").eq(0).text().split("/")[1]+""),t.push("")}t.push(""),t.push(""),e=I.loadXML(t.join("")),n.success&&n.success(e)},error:function(e,t){n.error&&n.error(e,t)}}),u.setRequestParam(l),u.submitRequest()},tt.prototype.startPlayback=function(e,t){var s=t.iWndIndex,n=t.szStartTime,r=t.szEndTime,o=k(t.cgi,t.urlProtocol,e.szIP,t.iPort,t.iChannelID,n,r);if(!W(t.oTransCodeParam)){var i=K(t.oTransCodeParam);if(""==i)return-1;c.HWP_SetTrsPlayBackParam(s,i)}var a=c.HWP_Play(o,e.szAuth,s,n,r);if(0==a){var u=new Q;u.iIndex=s,u.szIP=e.szIP,u.iChannelID=t.iChannelID,u.iPlayStatus=x,p.push(u)}return a},tt.prototype.reversePlayback=function(e,t){var s=t.iWndIndex,n=t.szStartTime,r=t.szEndTime,o=k(t.cgi,t.urlProtocol,e.szIP,t.iPort,t.iChannelID,n,r),i=c.HWP_ReversePlay(o,e.szAuth,s,n,r);if(0==i){var a=new Q;a.iIndex=s,a.szIP=e.szIP,a.iChannelID=t.iChannelID,a.iPlayStatus=D,p.push(a)}return i},tt.prototype.startDownloadRecord=function(e,t){var s=k(this.CGI.startDownloadRecord,e.szHttpProtocol,e.szIP,e.iCGIPort),n=" "+I.escape(t.szPlaybackURI)+"";return c.HWP_StartDownload(s,e.szAuth,t.szFileName,n)},tt.prototype.exportDeviceConfig=function(e){var t=k(this.CGI.deviceConfig,e.szHttpProtocol,e.szIP,e.iCGIPort);return c.HWP_ExportDeviceConfig(t,e.szAuth,"",0)},tt.prototype.importDeviceConfig=function(e,t){var s=k(this.CGI.deviceConfig,e.szHttpProtocol,e.szIP,e.iCGIPort);return c.HWP_ImportDeviceConfig(s,e.szAuth,t.szFileName,0)},tt.prototype.restart=function(e,t){var s=k(this.CGI.restart,e.szHttpProtocol,e.szIP,e.iCGIPort),n=new et,r={type:"PUT",url:s,auth:e.szAuth,success:null,error:null};I.extend(r,t),I.extend(r,{success:function(e){t.success&&t.success(e)},error:function(e,s){t.error&&t.error(e,s)}}),n.setRequestParam(r),n.submitRequest()},tt.prototype.restore=function(e,t,s){var n=k(this.CGI.restore,e.szHttpProtocol,e.szIP,e.iCGIPort,t),r=new et,o={type:"PUT",url:n,auth:e.szAuth,success:null,error:null};I.extend(o,s),I.extend(o,{success:function(e){s.success&&s.success(e)},error:function(e,t){s.error&&s.error(e,t)}}),r.setRequestParam(o),r.submitRequest()},tt.prototype.startUpgrade=function(e,t){var s=k(this.CGI.startUpgrade.upgrade,e.szHttpProtocol,e.szIP,e.iCGIPort),n=k(this.CGI.startUpgrade.status,e.szHttpProtocol,e.szIP,e.iCGIPort);return c.HWP_StartUpgrade(s,n,e.szAuth,t.szFileName)},tt.prototype.set3DZoom=function(e,t,n,r){var o=t.iChannelID,i="";i=o<=e.iAnalogChannelNum?k(this.CGI.set3DZoom,e.szHttpProtocol,e.szIP,e.iCGIPort,t.iChannelID):t.bShttpIPChannel?k(this.CGI.set3DZoom,e.szHttpProtocol,e.szIP,e.iCGIPort,t.iChannelID-e.oStreamCapa.iIpChanBase+1+e.iAnalogChannelNum):k(this.CGI.set3DZoom,e.szHttpProtocol,e.szIP,e.iCGIPort,t.iChannelID);var a=I.loadXML(n),c=parseInt(s.$XML(a).find("StartPoint").eq(0).find("positionX").eq(0).text(),10),u=parseInt(s.$XML(a).find("StartPoint").eq(0).find("positionY").eq(0).text(),10),l=parseInt(s.$XML(a).find("EndPoint").eq(0).find("positionX").eq(0).text(),10),p=parseInt(s.$XML(a).find("EndPoint").eq(0).find("positionY").eq(0).text(),10),d=""+c+""+(255-u)+""+l+""+(255-p)+"",P=new et,h={type:"PUT",url:i,data:d,auth:e.szAuth,success:null,error:null};I.extend(h,r),I.extend(h,{success:function(e){r.success&&r.success(e)},error:function(e,t){r.error&&r.error(e,t)}}),P.setRequestParam(h),P.submitRequest()},tt.prototype.getSDKCapa=function(e,t){var s=k(this.CGI.SDKCapabilities,e.szHttpProtocol,e.szIP,e.iCGIPort),n=new et,r={type:"GET",url:s,auth:e.szAuth,success:null,error:null};I.extend(r,t),I.extend(r,{success:function(e){t.success&&t.success(e)},error:function(e,s){t.error&&t.error(e,s)}}),n.setRequestParam(r),n.submitRequest()};var st=function(){};st.prototype.CGI={login:"%s%s:%s/PSIA/Custom/SelfExt/userCheck",getAudioInfo:"%s%s:%s/PSIA/Custom/SelfExt/TwoWayAudio/channels",getDeviceInfo:"%s%s:%s/PSIA/System/deviceInfo",getAnalogChannelInfo:"%s%s:%s/PSIA/System/Video/inputs/channels",getDigitalChannelInfo:"%s%s:%s/PSIA/Custom/SelfExt/ContentMgmt/DynVideo/inputs/channels/status",getZeroChannelInfo:"%s%s:%s/PSIA/Custom/SelfExt/ContentMgmt/ZeroVideo/channels",getStreamChannels:{analog:"%s%s:%s/PSIA/Streaming/channels",digital:"%s%s:%s/PSIA/Custom/SelfExt/ContentMgmt/DynStreaming/channels"},getStreamDynChannels:"%s%s:%s/PSIA/Custom/SelfExt/ContentMgmt/DynStreaming/channels",startRealPlay:{channels:"%s%s:%s/PSIA/streaming/channels/%s",zeroChannels:"%s%s:%s/PSIA/Custom/SelfExt/ContentMgmt/ZeroStreaming/channels/%s"},startVoiceTalk:{open:"%s%s:%s/PSIA/Custom/SelfExt/TwoWayAudio/channels/%s/open",close:"%s%s:%s/PSIA/Custom/SelfExt/TwoWayAudio/channels/%s/close",audioData:"%s%s:%s/PSIA/Custom/SelfExt/TwoWayAudio/channels/%s/audioData"},ptzControl:"%s%s:%s/PSIA/PTZ/channels/%s/continuous",ptzAutoControl:"%s%s:%s/PSIA/Custom/SelfExt/PTZ/channels/%s/autoptz",setPreset:"%s%s:%s/PSIA/PTZ/channels/%s/presets/%s",goPreset:"%s%s:%s/PSIA/PTZ/channels/%s/presets/%s/goto",ptzFocus:"%s%s:%s/PSIA/System/Video/inputs/channels/%s/focus",ptzIris:"%s%s:%s/PSIA/System/Video/inputs/channels/%s/iris",getNetworkBond:"%s%s:%s/PSIA/Custom/SelfExt/Bond",getNetworkInterface:"%s%s:%s/PSIA/System/Network/interfaces",getUPnPPortStatus:"%s%s:%s/PSIA/Custom/SelfExt/UPnP/ports/status",getPPPoEStatus:"%s%s:%s/PSIA/Custom/SelfExt/PPPoE/1/status",getPortInfo:"%s%s:%s/PSIA/Security/AAA/adminAccesses",recordSearch:"%s%s:%s/PSIA/ContentMgmt/search",startPlayback:"%s%s:%s/PSIA/streaming/tracks/%s?starttime=%s&endtime=%s",startDownloadRecord:"%s%s:%s/PSIA/Custom/SelfExt/ContentMgmt/download",deviceConfig:"%s%s:%s/PSIA/System/configurationData",restart:"%s%s:%s/PSIA/System/reboot",restore:"%s%s:%s/PSIA/System/factoryReset?mode=%s",startUpgrade:{upgrade:"%s%s:%s/PSIA/System/updateFirmware",status:"%s%s:%s/PSIA/Custom/SelfExt/upgradeStatus"},set3DZoom:"%s%s:%s/PSIA/Custom/SelfExt/PTZ/channels/%s/Set3DZoom"},st.prototype.login=function(e,t,n,r){var o=2==r.protocol?"https://":"http://",i=k(this.CGI.login,o,e,t),a=new et,c={type:"GET",url:i,auth:n,success:null,error:null};I.extend(c,r),I.extend(c,{success:function(e){"200"==s.$XML(e).find("statusValue").eq(0).text()?r.success&&r.success(e):r.error&&r.error(401,e)},error:function(e,t){r.error&&r.error(e,t)}}),a.setRequestParam(c),a.submitRequest()},st.prototype.getAudioInfo=function(e,t){var s=k(this.CGI.getAudioInfo,e.szHttpProtocol,e.szIP,e.iCGIPort),n=new et,r={type:"GET",url:s,auth:e.szAuth,success:null,error:null};I.extend(r,t),I.extend(r,{success:function(e){t.success&&t.success(e)},error:function(e,s){t.error&&t.error(e,s)}}),n.setRequestParam(r),n.submitRequest()},st.prototype.getDeviceInfo=function(e,t){var n=k(this.CGI.getDeviceInfo,e.szHttpProtocol,e.szIP,e.iCGIPort),r=new et,o={type:"GET",url:n,auth:e.szAuth,success:null,error:null};I.extend(o,t),I.extend(o,{success:function(e){var n=[];n.push(""),n.push(""+I.escape(s.$XML(e).find("deviceName").eq(0).text())+""),n.push(""+s.$XML(e).find("deviceID").eq(0).text()+""),n.push(""+s.$XML(e).find("deviceDescription").eq(0).text()+""),n.push(""+s.$XML(e).find("model").eq(0).text()+""),n.push(""+s.$XML(e).find("serialNumber").eq(0).text()+""),n.push(""+s.$XML(e).find("macAddress").eq(0).text()+""),n.push(""+s.$XML(e).find("firmwareVersion").eq(0).text()+""),n.push(""+s.$XML(e).find("firmwareReleasedDate").eq(0).text()+""),n.push(""+s.$XML(e).find("logicVersion").eq(0).text()+""),n.push(""+s.$XML(e).find("logicReleasedDate").eq(0).text()+""),n.push(""),e=I.loadXML(n.join("")),t.success&&t.success(e)},error:function(e,s){t.error&&t.error(e,s)}}),r.setRequestParam(o),r.submitRequest()},st.prototype.getAnalogChannelInfo=function(e,t){var n=k(this.CGI.getAnalogChannelInfo,e.szHttpProtocol,e.szIP,e.iCGIPort),r=new et,o={type:"GET",url:n,auth:e.szAuth,success:null,error:null};I.extend(o,t),I.extend(o,{success:function(e){var n=[];n.push("");for(var r=s.$XML(e).find("VideoInputChannel",!0),o=0,i=r.length;i>o;o++){var a=r[o];n.push(""),n.push(""+s.$XML(a).find("id").eq(0).text()+""),n.push(""+s.$XML(a).find("inputPort").eq(0).text()+""),n.push(""+I.escape(s.$XML(a).find("name").eq(0).text())+""),n.push(""+s.$XML(a).find("videoFormat").eq(0).text()+""),n.push("")}n.push(""),e=I.loadXML(n.join("")),t.success&&t.success(e)},error:function(e,s){t.error&&t.error(e,s)}}),r.setRequestParam(o),r.submitRequest()},st.prototype.getDigitalChannelInfo=function(e,t){var n=k(this.CGI.getDigitalChannelInfo,e.szHttpProtocol,e.szIP,e.iCGIPort),r=new et,o={type:"GET",url:n,auth:e.szAuth,success:null,error:null};I.extend(o,t),I.extend(o,{success:function(e){var n=[];n.push("");for(var r=s.$XML(e).find("DynVideoInputChannelStatus",!0),o=0,i=r.length;i>o;o++){var a=r[o];n.push(""),n.push(""+s.$XML(a).find("id").eq(0).text()+""),n.push(""),n.push(""+s.$XML(a).find("adminProtocol").eq(0).text()+""),n.push(""+s.$XML(a).find("addressingFormatType").eq(0).text()+""),n.push(""+s.$XML(a).find("ipAddress").eq(0).text()+""),n.push(""+s.$XML(a).find("adminPortNo").eq(0).text()+""),n.push(""+s.$XML(a).find("srcInputPort").eq(0).text()+""),n.push(""+I.escape(s.$XML(a).find("userName").eq(0).text())+""),n.push(""+s.$XML(a).find("streamType").eq(0).text()+""),n.push(""+s.$XML(a).find("online").eq(0).text()+""),n.push(""),n.push("")}n.push(""),e=I.loadXML(n.join("")),t.success&&t.success(e)},error:function(e,s){t.error&&t.error(e,s)}}),r.setRequestParam(o),r.submitRequest()},st.prototype.getZeroChannelInfo=function(e,t){var s=k(this.CGI.getZeroChannelInfo,e.szHttpProtocol,e.szIP,e.iCGIPort),n=new et,r={type:"GET",url:s,auth:e.szAuth,success:null,error:null};I.extend(r,t),I.extend(r,{success:function(e){t.success&&t.success(e)},error:function(e,s){t.error&&t.error(e,s)}}),n.setRequestParam(r),n.submitRequest()},st.prototype.getPPPoEStatus=function(e,t){var s=k(this.CGI.getPPPoEStatus,e.szHttpProtocol,e.szIP,e.iCGIPort),n=new et,r={type:"GET",url:s,auth:e.szAuth,success:null,error:null};I.extend(r,t),I.extend(r,{success:function(e){t.success&&t.success(e)},error:function(e,s){t.error&&t.error(e,s)}}),n.setRequestParam(r),n.submitRequest()},st.prototype.getUPnPPortStatus=function(e,t){var s=k(this.CGI.getUPnPPortStatus,e.szHttpProtocol,e.szIP,e.iCGIPort),n=new et,r={type:"GET",url:s,auth:e.szAuth,success:null,error:null};I.extend(r,t),I.extend(r,{success:function(e){t.success&&t.success(e)},error:function(e,s){t.error&&t.error(e,s)}}),n.setRequestParam(r),n.submitRequest()},st.prototype.getNetworkBond=function(e,t){var s=k(this.CGI.getNetworkBond,e.szHttpProtocol,e.szIP,e.iCGIPort),n=new et,r={type:"GET",url:s,auth:e.szAuth,success:null,error:null};I.extend(r,t),I.extend(r,{success:function(e){t.success&&t.success(e)},error:function(e,s){t.error&&t.error(e,s)}}),n.setRequestParam(r),n.submitRequest()},st.prototype.getNetworkInterface=function(e,t){var s=k(this.CGI.getNetworkInterface,e.szHttpProtocol,e.szIP,e.iCGIPort),n=new et,r={type:"GET",url:s,auth:e.szAuth,success:null,error:null};I.extend(r,t),I.extend(r,{success:function(e){t.success&&t.success(e)},error:function(e,s){t.error&&t.error(e,s)}}),n.setRequestParam(r),n.submitRequest()},st.prototype.getPortInfo=function(e,t){var n=k(this.CGI.getPortInfo,e.szHttpProtocol,e.szIP,e.iCGIPort),r=new et,o={type:"GET",url:n,auth:e.szAuth,success:null,error:null};I.extend(o,t),I.extend(o,{success:function(n){var r=[];r.push("");for(var o=s.$XML(n).find("AdminAccessProtocol",!0),i=0,a=o.length;a>i;i++){{o[i]}r.push(""),r.push(""+s.$XML(n).find("id").eq(0).text()+""),r.push(""+s.$XML(n).find("enabled").eq(0).text()+""),r.push(""+s.$XML(n).find("protocol").eq(0).text().toUpperCase()+""),r.push(""+s.$XML(n).find("portNo").eq(0).text()+""),r.push("")}h.getStreamChannels(e,{async:!1,success:function(n){if(s.$XML(n).find("rtspPortNo",!0).length>0){var o=parseInt(s.$XML(n).find("rtspPortNo").eq(0).text(),10);r.push(""),r.push("4"),r.push("true"),r.push("RTSP"),r.push(""+o+""),r.push(""),r.push("");var i=I.loadXML(r.join(""));t.success&&t.success(i)}else h.getStreamDynChannels(e,{async:!1,success:function(e){if(s.$XML(e).find("rtspPortNo",!0).length>0){var n=parseInt(s.$XML(e).find("rtspPortNo").eq(0).text(),10);r.push(""),r.push("4"),r.push("true"),r.push("RTSP"),r.push(""+n+""),r.push(""),r.push("");var o=I.loadXML(r.join(""));t.success&&t.success(o)}},error:function(){t.error&&t.error()}})},error:function(){t.error&&t.error()}})},error:function(){var n=[];n.push(""),h.getStreamChannels(e,{async:!1,success:function(r){if(s.$XML(r).find("rtspPortNo",!0).length>0){var o=parseInt(s.$XML(r).find("rtspPortNo").eq(0).text(),10);n.push(""),n.push("4"),n.push("true"),n.push("RTSP"),n.push(""+o+""),n.push(""),n.push("");var i=I.loadXML(n.join(""));t.success&&t.success(i)}else h.getStreamDynChannels(e,{async:!1,success:function(e){if(s.$XML(e).find("rtspPortNo",!0).length>0){var r=parseInt(s.$XML(e).find("rtspPortNo").eq(0).text(),10);n.push(""),n.push("4"),n.push("true"),n.push("RTSP"),n.push(""+r+""),n.push(""),n.push("");var o=I.loadXML(n.join(""));t.success&&t.success(o)}},error:function(){t.error&&t.error()}})},error:function(){t.error&&t.error()}})}}),r.setRequestParam(o),r.submitRequest()},st.prototype.getStreamChannels=function(e,t){if(0!=e.iAnalogChannelNum)var s=k(this.CGI.getStreamChannels.analog,e.szHttpProtocol,e.szIP,e.iCGIPort);else var s=k(this.CGI.getStreamChannels.digital,e.szHttpProtocol,e.szIP,e.iCGIPort);var n=new et,r={type:"GET",url:s,auth:e.szAuth,success:null,error:null};I.extend(r,t),I.extend(r,{success:function(e){t.success&&t.success(e)},error:function(e,s){t.error&&t.error(e,s)}}),n.setRequestParam(r),n.submitRequest()},st.prototype.getStreamDynChannels=function(e,t){var s=k(this.CGI.getStreamDynChannels,e.szHttpProtocol,e.szIP,e.iCGIPort),n=new et,r={type:"GET",url:s,auth:e.szAuth,success:null,error:null};I.extend(r,t),I.extend(r,{success:function(e){t.success&&t.success(e)},error:function(e,s){t.error&&t.error(e,s)}}),n.setRequestParam(r),n.submitRequest()},st.prototype.startRealPlay=function(e,t){var s=100*t.iChannelID+t.iStreamType,n="";n=t.bZeroChannel?k(t.cgi.zeroChannels,t.urlProtocol,e.szIP,t.iPort,s):k(t.cgi.channels,t.urlProtocol,e.szIP,t.iPort,s);var r=c.HWP_Play(n,e.szAuth,t.iWndIndex,"","");if(0==r){var o=new Q;o.iIndex=t.iWndIndex,o.szIP=e.szIP,o.iChannelID=t.iChannelID,o.iPlayStatus=v,p.push(o)}return r},st.prototype.startVoiceTalk=function(e,t){var s=k(this.CGI.startVoiceTalk.open,e.szHttpProtocol,e.szIP,e.iCGIPort,t),n=k(this.CGI.startVoiceTalk.close,e.szHttpProtocol,e.szIP,e.iCGIPort,t),r=k(this.CGI.startVoiceTalk.audioData,e.szHttpProtocol,e.szIP,e.iCGIPort,t),o=c.HWP_StartVoiceTalk(s,n,r,e.szAuth,e.iAudioType);return o},st.prototype.ptzAutoControl=function(e,t,s,n){var r=s.iChannelID,o="",i="";if(n.iPTZSpeed=n.iPTZSpeed<7?15*n.iPTZSpeed:100,t&&(n.iPTZSpeed=0),e.szDeviceType!=X)o=k(this.CGI.ptzAutoControl,e.szHttpProtocol,e.szIP,e.iCGIPort,r),i=""+n.iPTZSpeed+"0";else{var a=99;t&&(a=96),o=k(this.CGI.goPreset,e.szHttpProtocol,e.szIP,e.iCGIPort,r,a)}var c=new et,u={type:"PUT",url:o,async:!1,auth:e.szAuth,data:i,success:null,error:null},l=this;I.extend(u,n),I.extend(u,{success:function(e){s.bPTZAuto=!s.bPTZAuto,n.success&&n.success(e)},error:function(t,r){if(e.szDeviceType!=X){o=k(l.CGI.ptzControl,e.szHttpProtocol,e.szIP,e.iCGIPort,s.iChannelID);var a=new et,c={type:"PUT",url:o,async:!1,auth:e.szAuth,data:i,success:null,error:null};I.extend(c,n),a.setRequestParam(c),a.submitRequest()}else n.error&&n.error(t,r)}}),c.setRequestParam(u),c.submitRequest()},st.prototype.ptzControl=function(e,t,s,n){var r=(s.iChannelID,"");s.bPTZAuto&&this.ptzAutoControl(e,!0,s,{iPTZSpeed:0}),n.iPTZSpeed=t?0:n.iPTZSpeed<7?15*n.iPTZSpeed:100;var o=[{},{pan:0,tilt:n.iPTZSpeed},{pan:0,tilt:-n.iPTZSpeed},{pan:-n.iPTZSpeed,tilt:0},{pan:n.iPTZSpeed,tilt:0},{pan:-n.iPTZSpeed,tilt:n.iPTZSpeed},{pan:-n.iPTZSpeed,tilt:-n.iPTZSpeed},{pan:n.iPTZSpeed,tilt:n.iPTZSpeed},{pan:n.iPTZSpeed,tilt:-n.iPTZSpeed},{},{speed:n.iPTZSpeed},{speed:-n.iPTZSpeed},{speed:n.iPTZSpeed},{speed:-n.iPTZSpeed},{speed:n.iPTZSpeed},{speed:-n.iPTZSpeed}],i="",a={};switch(n.iPTZIndex){case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:a=this.CGI.ptzControl,i=""+o[n.iPTZIndex].pan+""+o[n.iPTZIndex].tilt+"";break;case 10:case 11:a=this.CGI.ptzControl,i=""+o[n.iPTZIndex].speed+"";break;case 12:case 13:a=this.CGI.ptzFocus,i=""+o[n.iPTZIndex].speed+"";break;case 14:case 15:a=this.CGI.ptzIris,i=""+o[n.iPTZIndex].speed+"";break;default:return void(W(n.error)&&n.error())}r=k(a,e.szHttpProtocol,e.szIP,e.iCGIPort,s.iChannelID);var c=new et,u={type:"PUT",url:r,async:!1,auth:e.szAuth,data:i,success:null,error:null};I.extend(u,n),I.extend(u,{success:function(e){n.success&&n.success(e)},error:function(e,t){n.error&&n.error(e,t)}}),c.setRequestParam(u),c.submitRequest()},st.prototype.setPreset=function(e,t,s){var n=(t.iChannelID,""),r="";n=k(this.CGI.setPreset,e.szHttpProtocol,e.szIP,e.iCGIPort,t.iChannelID,s.iPresetID),r="",r+="",r+=""+s.iPresetID+"",e.szDeviceType!=X&&(r+="Preset"+s.iPresetID+""),r+="";var o=new et,i={type:"PUT",url:n,auth:e.szAuth,data:r,success:null,error:null};I.extend(i,s),I.extend(i,{success:function(e){s.success&&s.success(e)},error:function(e,t){s.error&&s.error(e,t)}}),o.setRequestParam(i),o.submitRequest()},st.prototype.goPreset=function(e,t,s){var n=(t.iChannelID,"");n=k(this.CGI.goPreset,e.szHttpProtocol,e.szIP,e.iCGIPort,t.iChannelID,s.iPresetID);var r=new et,o={type:"PUT",url:n,auth:e.szAuth,success:null,error:null};I.extend(o,s),I.extend(o,{success:function(e){s.success&&s.success(e)},error:function(e,t){s.error&&s.error(e,t)}}),r.setRequestParam(o),r.submitRequest()},st.prototype.recordSearch=function(e,n){var r="",o="",i=n.iChannelID,a=n.szStartTime.replace(" ","T")+"Z",c=n.szEndTime.replace(" ","T")+"Z";r=k(this.CGI.recordSearch,e.szHttpProtocol,e.szIP,e.iCGIPort),o=""+new t+""+(100*i+1)+""+a+""+c+"40"+n.iSearchPos+"//metadata.psia.org/VideoMotion"; 3 | var u=new et,l={type:"POST",url:r,auth:e.szAuth,data:o,success:null,error:null};I.extend(l,n),I.extend(l,{success:function(e){var t=[];t.push(""),t.push(""+s.$XML(e).find("responseStatus").eq(0).text()+""),t.push(""+s.$XML(e).find("responseStatusStrg").eq(0).text()+""),t.push(""+s.$XML(e).find("numOfMatches").eq(0).text()+""),t.push("");for(var r=s.$XML(e).find("searchMatchItem",!0),o=0,i=r.length;i>o;o++){var a=r[o];t.push(""),t.push(""+s.$XML(a).find("trackID").eq(0).text()+""),t.push(""+s.$XML(a).find("startTime").eq(0).text()+""),t.push(""+s.$XML(a).find("endTime").eq(0).text()+""),t.push(""+I.escape(s.$XML(a).find("playbackURI").eq(0).text())+""),t.push(""+s.$XML(a).find("metadataDescriptor").eq(0).text().split("/")[1]+""),t.push("")}t.push(""),t.push(""),e=I.loadXML(t.join("")),n.success&&n.success(e)},error:function(e,t){n.error&&n.error(e,t)}}),u.setRequestParam(l),u.submitRequest()},st.prototype.startPlayback=function(e,t){var s=t.iWndIndex,n=t.szStartTime,r=t.szEndTime,o=k(t.cgi,t.urlProtocol,e.szIP,t.iPort,t.iChannelID,n,r),i=c.HWP_Play(o,e.szAuth,s,n,r);if(0==i){var a=new Q;a.iIndex=s,a.szIP=e.szIP,a.iChannelID=t.iChannelID,a.iPlayStatus=x,p.push(a)}return i},st.prototype.reversePlayback=function(e,t){var s=t.iWndIndex,n=t.szStartTime,r=t.szEndTime,o=k(t.cgi,t.urlProtocol,e.szIP,t.iPort,t.iChannelID,n,r),i=c.HWP_ReversePlay(o,e.szAuth,s,n,r);if(0==i){var a=new Q;a.iIndex=s,a.szIP=e.szIP,a.iChannelID=t.iChannelID,a.iPlayStatus=D,p.push(a)}return i},st.prototype.startDownloadRecord=function(e,t){var s=k(this.CGI.startDownloadRecord,e.szHttpProtocol,e.szIP,e.iCGIPort),n=" "+I.escape(t.szPlaybackURI)+"";return c.HWP_StartDownload(s,e.szAuth,t.szFileName,n)},st.prototype.exportDeviceConfig=function(e){var t=k(this.CGI.deviceConfig,e.szHttpProtocol,e.szIP,e.iCGIPort);return c.HWP_ExportDeviceConfig(t,e.szAuth,"",0)},st.prototype.importDeviceConfig=function(e,t){var s=k(this.CGI.deviceConfig,e.szHttpProtocol,e.szIP,e.iCGIPort);return c.HWP_ImportDeviceConfig(s,e.szAuth,t.szFileName,0)},st.prototype.restart=function(e,t){var s=k(this.CGI.restart,e.szHttpProtocol,e.szIP,e.iCGIPort),n=new et,r={type:"PUT",url:s,auth:e.szAuth,success:null,error:null};I.extend(r,t),I.extend(r,{success:function(e){t.success&&t.success(e)},error:function(e,s){t.error&&t.error(e,s)}}),n.setRequestParam(r),n.submitRequest()},st.prototype.restore=function(e,t,s){var n=k(this.CGI.restore,e.szHttpProtocol,e.szIP,e.iCGIPort,t),r=new et,o={type:"PUT",url:n,auth:e.szAuth,success:null,error:null};I.extend(o,s),I.extend(o,{success:function(e){s.success&&s.success(e)},error:function(e,t){s.error&&s.error(e,t)}}),r.setRequestParam(o),r.submitRequest()},st.prototype.startUpgrade=function(e,t){var s=k(this.CGI.startUpgrade.upgrade,e.szHttpProtocol,e.szIP,e.iCGIPort),n=k(this.CGI.startUpgrade.status,e.szHttpProtocol,e.szIP,e.iCGIPort);return c.HWP_StartUpgrade(s,n,e.szAuth,t.szFileName)},st.prototype.set3DZoom=function(e,t,s,n){var r=k(this.CGI.set3DZoom,e.szHttpProtocol,e.szIP,e.iCGIPort,t.iChannelID),o=new et,i={type:"PUT",url:r,data:s,auth:e.szAuth,success:null,error:null};I.extend(i,n),I.extend(i,{success:function(e){n.success&&n.success(e)},error:function(e,t){n.error&&n.error(e,t)}}),o.setRequestParam(i),o.submitRequest()};var nt=function(){};nt.prototype._alert=function(e){a.bDebugMode&&console.log(e)},function(t){var s=function(e){this.elems=[],this.length=0,this.length=this.elems.push(e)};s.prototype.find=function(e,t){var s=this.elems[this.length-1].getElementsByTagName(e);return this.length=this.elems.push(s),t?s:this},s.prototype.eq=function(e,t){var s=this.elems[this.length-1].length,n=null;return s>0&&s>e&&(n=this.elems[this.length-1][e]),this.length=this.elems.push(n),t?n:this},s.prototype.text=function(t){return this.elems[this.length-1]?t?void(e.DOMParser?this.elems[this.length-1].textContent=t:this.elems[this.length-1].text=t):e.DOMParser?this.elems[this.length-1].textContent:this.elems[this.length-1].text:""},s.prototype.attr=function(e){if(this.elems[this.length-1]){var t=this.elems[this.length-1].attributes.getNamedItem(e);return t?t.value:""}},t.$XML=function(e){return new s(e)}}(this);var rt=function(){};rt.prototype.extend=function(){for(var e,t=arguments[0]||{},s=1,n=arguments.length;n>s;s++)if(null!=(e=arguments[s]))for(var r in e){var o=(t[r],e[r]);t!==o&&("object"==typeof o?t[r]=this.extend({},o):void 0!==o&&(t[r]=o))}return t},rt.prototype.browser=function(){var e=/(webkit)[ \/]([\w.]+)/,t=/(opera)(?:.*version)?[ \/]([\w.]+)/,s=/(msie) ([\w.]+)/,n=/(trident.*rv:)([\w.]+)/,r=/(mozilla)(?:.*? rv:([\w.]+))?/,o=navigator.userAgent.toLowerCase(),i=e.exec(o)||t.exec(o)||s.exec(o)||n.exec(o)||o.indexOf("compatible")<0&&r.exec(o)||["unknow","0"];i.length>0&&i[1].indexOf("trident")>-1&&(i[1]="msie"),"webkit"==i[1]&&(i[1]=o.indexOf("chrome")>-1?"chrome":"safari");var a={};return a[i[1]]=!0,a.version=i[2],a},rt.prototype.loadXML=function(t){if(null==t||""==t)return null;var s=null;if(e.DOMParser){var n=new DOMParser;s=n.parseFromString(t,"text/xml")}else s=new ActiveXObject("Microsoft.XMLDOM"),s.async=!1,s.loadXML(t);return s},rt.prototype.toXMLStr=function(e){var t="";try{var s=new XMLSerializer;t=s.serializeToString(e)}catch(n){try{t=e.xml}catch(n){return""}}return-1==t.indexOf(""+t),t},rt.prototype.escape=function(e){return e.replace(/&/g,"&").replace(//g,">")},rt.prototype.dateFormat=function(e,t){var s={"M+":e.getMonth()+1,"d+":e.getDate(),"h+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(e.getFullYear()+"").substr(4-RegExp.$1.length)));for(var n in s)new RegExp("("+n+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?s[n]:("00"+s[n]).substr((""+s[n]).length)));return t},rt.prototype.Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var t,s,n,r,o,i,a,c="",u=0;for(e=rt.prototype.Base64._utf8_encode(e);u>2,o=(3&t)<<4|s>>4,i=(15&s)<<2|n>>6,a=63&n,isNaN(s)?i=a=64:isNaN(n)&&(a=64),c=c+this._keyStr.charAt(r)+this._keyStr.charAt(o)+this._keyStr.charAt(i)+this._keyStr.charAt(a);return c},decode:function(e){var t,s,n,r,o,i,a,c="",u=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");u>4,s=(15&o)<<4|i>>2,n=(3&i)<<6|a,c+=String.fromCharCode(t),64!=i&&(c+=String.fromCharCode(s)),64!=a&&(c+=String.fromCharCode(n));return c=rt.prototype.Base64._utf8_decode(c)},_utf8_encode:function(e){e=e.replace(/\r\n/g,"\n");for(var t="",s=0;sn?t+=String.fromCharCode(n):n>127&&2048>n?(t+=String.fromCharCode(n>>6|192),t+=String.fromCharCode(63&n|128)):(t+=String.fromCharCode(n>>12|224),t+=String.fromCharCode(n>>6&63|128),t+=String.fromCharCode(63&n|128))}return t},_utf8_decode:function(e){for(var t="",s=0,n=c1=c2=0;sn?(t+=String.fromCharCode(n),s++):n>191&&224>n?(c2=e.charCodeAt(s+1),t+=String.fromCharCode((31&n)<<6|63&c2),s+=2):(c2=e.charCodeAt(s+1),c3=e.charCodeAt(s+2),t+=String.fromCharCode((15&n)<<12|(63&c2)<<6|63&c3),s+=3);return t}},t.prototype.valueOf=function(){return this.id},t.prototype.toString=function(){return this.id},t.prototype.createUUID=function(){var e=new Date(1582,10,15,0,0,0,0),s=new Date,n=s.getTime()-e.getTime(),r="-",o=t.getIntegerBits(n,0,31),i=t.getIntegerBits(n,32,47),a=t.getIntegerBits(n,48,59)+"1",c=t.getIntegerBits(t.rand(4095),0,7),u=t.getIntegerBits(t.rand(4095),0,7),l=t.getIntegerBits(t.rand(8191),0,7)+t.getIntegerBits(t.rand(8191),8,15)+t.getIntegerBits(t.rand(8191),0,7)+t.getIntegerBits(t.rand(8191),8,15)+t.getIntegerBits(t.rand(8191),0,15);return o+r+i+r+a+r+c+u+r+l},t.getIntegerBits=function(e,s,n){var r=t.returnBase(e,16),o=new Array,i="",a=0;for(a=0;ae)var n=s[e];else{var r=""+Math.floor(e/t),o=e-r*t;if(r>=t)var n=this.returnBase(r,t)+s[o];else var n=s[r]+s[o]}return n},t.rand=function(e){return Math.floor(Math.random()*e)},P=new tt,h=new st,d=new nt,I=new rt;var ot=I.dateFormat(new Date,"yyyyMMddhhmmss");if(o="webVideoCtrl"+ot,i="webVideoCtrl"+ot,"object"!=typeof e.attachEvent&&I.browser().msie){var it="";it+="",it+="",it+="",document.write(it)}return this}(),s=e.WebVideoCtrl=t;s.version="1.0.5"}}(this); -------------------------------------------------------------------------------- /example-en/demo.css: -------------------------------------------------------------------------------- 1 | @charset "utf-8"; 2 | * 3 | { 4 | margin:0; 5 | padding:0; 6 | } 7 | html 8 | { 9 | width:100%; 10 | height:100%; 11 | font-size:12px; 12 | font-family:Arial, Helvetica, sans-serif; 13 | -webkit-text-size-adjust:none; 14 | background:#FFFFFF; 15 | } 16 | body 17 | { 18 | padding:5px; 19 | } 20 | select 21 | { 22 | height:20px; 23 | line-height:20px; 24 | } 25 | .left 26 | { 27 | float:left; 28 | } 29 | .freeze 30 | { 31 | position:absolute; 32 | text-align:center; 33 | background:#343434; 34 | color:#FFFFFF; 35 | font-size:26px; 36 | font-weight:bold; 37 | filter:alpha(opacity=60); 38 | opacity:0.6; 39 | } 40 | .vtop 41 | { 42 | vertical-align:middle; 43 | margin-top:-1px; 44 | } 45 | /*插件*/ 46 | .plugin 47 | { 48 | width:500px; 49 | height:300px; 50 | } 51 | fieldset 52 | { 53 | display:block; 54 | } 55 | /*本地配置*/ 56 | .localconfig 57 | { 58 | width:480px; 59 | padding:10px; 60 | border:1px solid #7F9DB9; 61 | } 62 | .localconfig .tt 63 | { 64 | width:125px; 65 | } 66 | .localconfig .txt 67 | { 68 | width:260px; 69 | } 70 | .localconfig .btn 71 | { 72 | width:50px; 73 | height:22px; 74 | line-height:18px; 75 | } 76 | .localconfig .sel 77 | { 78 | width:120px; 79 | } 80 | /*登录*/ 81 | .login 82 | { 83 | width:480px; 84 | padding:10px; 85 | border:1px solid #7F9DB9; 86 | } 87 | .login .tt 88 | { 89 | width:100px; 90 | } 91 | .login .txt 92 | { 93 | width:130px; 94 | } 95 | .login .btn 96 | { 97 | width:48px; 98 | height:22px; 99 | line-height:18px; 100 | } 101 | .login .btn2 102 | { 103 | width:100px; 104 | height:22px; 105 | line-height:18px; 106 | } 107 | .login .sel 108 | { 109 | width:130px; 110 | } 111 | .login .sel2 112 | { 113 | width:55px; 114 | } 115 | /*数字通道*/ 116 | .ipchannel 117 | { 118 | width:480px; 119 | padding:10px; 120 | border:1px solid #7F9DB9; 121 | } 122 | .ipchannel .btn 123 | { 124 | width:150px; 125 | height:22px; 126 | line-height:18px; 127 | } 128 | .ipchannel .digitaltdiv 129 | { 130 | height:100px; 131 | overflow:hidden; 132 | overflow-y:auto; 133 | border:1px solid #7F9DB9; 134 | font-size:11px; 135 | } 136 | .ipchannel .digitalchannellist th, .ipchannel .digitalchannellist td 137 | { 138 | padding:2px; 139 | border:1px solid #7F9DB9; 140 | border-collapse:collapse; 141 | white-space:nowrap; 142 | } 143 | /*预览*/ 144 | .preview 145 | { 146 | width:450px; 147 | padding:10px; 148 | padding-top:0; 149 | margin-left:10px; 150 | border:1px solid #7F9DB9; 151 | } 152 | .preview .tt 153 | { 154 | width:60px; 155 | } 156 | .preview .txt 157 | { 158 | width:30px; 159 | } 160 | .preview .btn 161 | { 162 | width:75px; 163 | height:22px; 164 | line-height:18px; 165 | } 166 | .preview .btn2 167 | { 168 | width:105px; 169 | height:22px; 170 | line-height:18px; 171 | } 172 | .preview .sel 173 | { 174 | width:95px; 175 | } 176 | /*云台*/ 177 | .ptz 178 | { 179 | width:450px; 180 | padding:10px; 181 | margin-left:10px; 182 | border:1px solid #7F9DB9; 183 | } 184 | .ptz .tt 185 | { 186 | width:60px; 187 | } 188 | .ptz .txt 189 | { 190 | width:60px; 191 | } 192 | .ptz .btn 193 | { 194 | width:45px; 195 | height:22px; 196 | line-height:18px; 197 | } 198 | .ptz .btn2 199 | { 200 | width:60px; 201 | height:22px; 202 | line-height:18px; 203 | } 204 | .ptz .sel 205 | { 206 | width:65px; 207 | } 208 | /*视频参数*/ 209 | .videoparam 210 | { 211 | width:450px; 212 | padding:10px; 213 | margin-left:10px; 214 | border:1px solid #7F9DB9; 215 | } 216 | .videoparam .tt 217 | { 218 | width:60px; 219 | } 220 | .videoparam .txt 221 | { 222 | width:60px; 223 | } 224 | .videoparam .btn 225 | { 226 | width:45px; 227 | height:22px; 228 | line-height:18px; 229 | } 230 | .videoparam .sel 231 | { 232 | width:65px; 233 | } 234 | /*回放*/ 235 | .playback 236 | { 237 | width:450px; 238 | padding:10px; 239 | margin-left:10px; 240 | border:1px solid #7F9DB9; 241 | } 242 | .playback .tt 243 | { 244 | width:60px; 245 | } 246 | .playback .txt 247 | { 248 | width:120px; 249 | } 250 | .playback .btn 251 | { 252 | width:105px; 253 | height:22px; 254 | line-height:18px; 255 | } 256 | .playback .btn2 257 | { 258 | width:105px; 259 | height:22px; 260 | line-height:18px; 261 | } 262 | .playback .sel 263 | { 264 | width:65px; 265 | } 266 | .playback .searchdiv 267 | { 268 | height:100px; 269 | overflow:hidden; 270 | overflow-y:auto; 271 | border:1px solid #7F9DB9; 272 | font-size:11px; 273 | } 274 | .playback .searchlist th, .playback .searchlist td 275 | { 276 | padding:2px; 277 | border:1px solid #7F9DB9; 278 | border-collapse:collapse; 279 | white-space:nowrap; 280 | } 281 | /*系统维护*/ 282 | .maintain 283 | { 284 | width:450px; 285 | padding:10px; 286 | margin-left:10px; 287 | border:1px solid #7F9DB9; 288 | } 289 | .maintain .tt 290 | { 291 | width:60px; 292 | } 293 | .maintain .txt 294 | { 295 | width:263px; 296 | } 297 | .maintain .btn 298 | { 299 | width:50px; 300 | height:22px; 301 | line-height:18px; 302 | } 303 | .maintain .btn2 304 | { 305 | width:105px; 306 | height:22px; 307 | line-height:18px; 308 | } 309 | .maintain .sel 310 | { 311 | width:65px; 312 | } 313 | /*操作信息*/ 314 | .operate 315 | { 316 | width:450px; 317 | padding:10px; 318 | margin-left:10px; 319 | border:1px solid #7F9DB9; 320 | } 321 | .operate .opinfo 322 | { 323 | height:100px; 324 | border:1px solid #7F9DB9; 325 | overflow:auto; 326 | } 327 | /*事件回调*/ 328 | .callback 329 | { 330 | width:450px; 331 | padding:10px; 332 | margin-left:10px; 333 | border:1px solid #7F9DB9; 334 | } 335 | .callback .cbinfo 336 | { 337 | height:53px; 338 | border:1px solid #7F9DB9; 339 | overflow:auto; 340 | } 341 | /*IP resolve*/ 342 | .ipparse 343 | { 344 | width:480px; 345 | padding:10px; 346 | border:1px solid #7F9DB9; 347 | } 348 | .ipparse .tt 349 | { 350 | width:100px; 351 | } 352 | .ipparse .txt 353 | { 354 | width:130px; 355 | } 356 | .ipparse .btn 357 | { 358 | width:90px; 359 | height:22px; 360 | line-height:18px; 361 | } 362 | .ipparse .sel 363 | { 364 | width:130px; 365 | } -------------------------------------------------------------------------------- /example-en/demo.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 14 |
15 |
16 |
17 | Device IP Resolve 18 | 19 | 20 | 21 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 |
Mode 22 | 26 |
Server AddressServer Port
Device Name 
41 |
42 | 89 |
90 | Digital channel 91 | 92 | 93 | 94 | 95 | 96 | 101 | 102 |
97 |
98 |
99 |
100 |
103 |
104 |
105 | Local configuration 106 | 107 | 108 | 109 | 117 | 118 | 125 | 126 | 127 | 128 | 134 | 135 | 141 | 142 | 143 | 144 | 151 | 152 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 |
Play performance 110 | 116 | Image size 119 | 124 |
Rules 129 | 133 | Snapshot format 136 | 140 |
Package size 145 | 150 | Protocol 153 | 157 |
Save record files to 
Save downloaded files to 
Save snapshots in live view to 
Save snapshots when playback to 
Save clips to 
 
183 |
184 |
185 |
186 |
187 | Browse 188 | 189 | 190 | 191 | 197 | 201 | 202 | 203 | 204 | 207 | 211 | 212 | 213 | 214 | 220 | 224 | 225 | 226 | 232 | 233 | 234 | 240 | 241 |
Stream type 192 | 196 | 198 | 199 | 200 |
Volume 205 |  (Range:0~100) 206 | 208 | 209 | 210 |
Voice channel 215 | 218 | 219 | 221 | 222 | 223 |
227 | 228 | 229 | 230 | 231 |
235 | 236 | 237 | 238 | 239 |
242 |
243 |
244 | PTZ control 245 | 246 | 247 | 252 | 253 | 254 | 259 | 260 | 261 | 266 | 267 |
248 | 249 | 250 | 251 |
255 | 256 | 257 | 258 |
262 | 263 | 264 | 265 |
268 | 269 | 270 | 271 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 292 | 293 |
PTZ speed 272 | 281 |
Preset
289 | 290 | 291 |
294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 |
308 |
309 |
310 | Playback 311 | 312 | 313 | 314 | 317 | 318 | 319 | 320 | 324 | 325 | 326 | 331 | 332 | 333 | 340 | 341 | 342 | 348 | 349 | 350 | 356 | 357 |
Start time 315 | (Time format:2013-11-11 12:34:56) 316 |
End time 321 | 322 | 323 |
327 |
328 |
329 |
330 |
334 | 335 | 336 | 337 | 338 |  Enable TransCode Stream 339 |
343 | 344 | 345 | 346 | 347 |
351 | 352 | 353 | 354 |   355 |
358 |
359 |
360 | System maintenance 361 | 362 | 363 | 369 | 370 | 371 | 374 | 375 | 376 | 379 | 380 |
364 | 365 | 366 | 367 | 368 |
372 |    373 |
377 |    378 |
381 |
382 |
383 | Operation information 384 |
385 |
386 |
387 | Event callback information 388 |
389 |
390 |
391 | 392 | 393 | 394 | 395 | 396 | -------------------------------------------------------------------------------- /example-en/demo.js: -------------------------------------------------------------------------------- 1 | // Init plugin 2 | 3 | // overall save the current selected window 4 | var g_iWndIndex = 0; //don't have to set the variable; default to use the current selected window without transmiting value when the interface has window parameters 5 | $(function () { 6 | // check the installation status of plugin 7 | if (-1 == WebVideoCtrl.I_CheckPluginInstall()) { 8 | alert(" If the plugin is uninstalled, please install the WebComponents.exe!"); 9 | return; 10 | } 11 | 12 | // Init plugin parameters and insert the plugin 13 | WebVideoCtrl.I_InitPlugin(500, 300, { 14 | iWndowType: 2, 15 | cbSelWnd: function (xmlDoc) { 16 | g_iWndIndex = $(xmlDoc).find("SelectWnd").eq(0).text(); 17 | var szInfo = "selected window number:" + g_iWndIndex; 18 | showCBInfo(szInfo); 19 | } 20 | }); 21 | WebVideoCtrl.I_InsertOBJECTPlugin("divPlugin"); 22 | 23 | // check plugin to see whether it is the latest 24 | if (-1 == WebVideoCtrl.I_CheckPluginVersion()) { 25 | alert("Detect the latest version, please double click WebComponents.exe to update!"); 26 | return; 27 | } 28 | 29 | // window event binding 30 | $(window).bind({ 31 | resize: function () { 32 | var $Restart = $("#restartDiv"); 33 | if ($Restart.length > 0) { 34 | var oSize = getWindowSize(); 35 | $Restart.css({ 36 | width: oSize.width + "px", 37 | height: oSize.height + "px" 38 | }); 39 | } 40 | } 41 | }); 42 | 43 | //init date 44 | var szCurTime = dateFormat(new Date(), "yyyy-MM-dd"); 45 | $("#starttime").val(szCurTime + " 00:00:00"); 46 | $("#endtime").val(szCurTime + " 23:59:59"); 47 | }); 48 | 49 | // display operation info 50 | function showOPInfo(szInfo) { 51 | szInfo = "
" + dateFormat(new Date(), "yyyy-MM-dd hh:mm:ss") + " " + szInfo + "
"; 52 | $("#opinfo").html(szInfo + $("#opinfo").html()); 53 | } 54 | 55 | // display callback info 56 | function showCBInfo(szInfo) { 57 | szInfo = "
" + dateFormat(new Date(), "yyyy-MM-dd hh:mm:ss") + " " + szInfo + "
"; 58 | $("#cbinfo").html(szInfo + $("#cbinfo").html()); 59 | } 60 | 61 | // time format 62 | function dateFormat(oDate, fmt) { 63 | var o = { 64 | "M+": oDate.getMonth() + 1, //month 65 | "d+": oDate.getDate(), //day 66 | "h+": oDate.getHours(), //hour 67 | "m+": oDate.getMinutes(), //minute 68 | "s+": oDate.getSeconds(), //second 69 | "q+": Math.floor((oDate.getMonth() + 3) / 3), //quarter 70 | "S": oDate.getMilliseconds()//millisecond 71 | }; 72 | if (/(y+)/.test(fmt)) { 73 | fmt = fmt.replace(RegExp.$1, (oDate.getFullYear() + "").substr(4 - RegExp.$1.length)); 74 | } 75 | for (var k in o) { 76 | if (new RegExp("(" + k + ")").test(fmt)) { 77 | fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); 78 | } 79 | } 80 | return fmt; 81 | } 82 | 83 | // get window size 84 | function getWindowSize() { 85 | var nWidth = $(this).width() + $(this).scrollLeft(), 86 | nHeight = $(this).height() + $(this).scrollTop(); 87 | 88 | return {width: nWidth, height: nHeight}; 89 | } 90 | 91 | // open option dialog 0: folder, 1: file 92 | function clickOpenFileDlg(id, iType) { 93 | var szDirPath = WebVideoCtrl.I_OpenFileDlg(iType); 94 | 95 | if (szDirPath != -1 && szDirPath != "" && szDirPath != null) { 96 | $("#" + id).val(szDirPath); 97 | } 98 | } 99 | 100 | // get local parameters 101 | function clickGetLocalCfg() { 102 | var xmlDoc = WebVideoCtrl.I_GetLocalCfg(); 103 | 104 | $("#netsPreach").val($(xmlDoc).find("BuffNumberType").eq(0).text()); 105 | $("#wndSize").val($(xmlDoc).find("PlayWndType").eq(0).text()); 106 | $("#rulesInfo").val($(xmlDoc).find("IVSMode").eq(0).text()); 107 | $("#captureFileFormat").val($(xmlDoc).find("CaptureFileFormat").eq(0).text()); 108 | $("#packSize").val($(xmlDoc).find("PackgeSize").eq(0).text()); 109 | $("#recordPath").val($(xmlDoc).find("RecordPath").eq(0).text()); 110 | $("#downloadPath").val($(xmlDoc).find("DownloadPath").eq(0).text()); 111 | $("#previewPicPath").val($(xmlDoc).find("CapturePath").eq(0).text()); 112 | $("#playbackPicPath").val($(xmlDoc).find("PlaybackPicPath").eq(0).text()); 113 | $("#playbackFilePath").val($(xmlDoc).find("PlaybackFilePath").eq(0).text()); 114 | $("#protocolType").val($(xmlDoc).find("ProtocolType").eq(0).text()); 115 | 116 | showOPInfo("local configuration success!"); 117 | } 118 | 119 | // set local parameters 120 | function clickSetLocalCfg() { 121 | var arrXml = [], 122 | szInfo = ""; 123 | 124 | arrXml.push(""); 125 | arrXml.push("" + $("#packSize").val() + ""); 126 | arrXml.push("" + $("#wndSize").val() + ""); 127 | arrXml.push("" + $("#netsPreach").val() + ""); 128 | arrXml.push("" + $("#recordPath").val() + ""); 129 | arrXml.push("" + $("#previewPicPath").val() + ""); 130 | arrXml.push("" + $("#playbackFilePath").val() + ""); 131 | arrXml.push("" + $("#playbackPicPath").val() + ""); 132 | arrXml.push("" + $("#downloadPath").val() + ""); 133 | arrXml.push("" + $("#rulesInfo").val() + ""); 134 | arrXml.push("" + $("#captureFileFormat").val() + ""); 135 | arrXml.push("" + $("#protocolType").val() + ""); 136 | arrXml.push(""); 137 | 138 | var iRet = WebVideoCtrl.I_SetLocalCfg(arrXml.join("")); 139 | 140 | if (0 == iRet) { 141 | szInfo = "local configuration success!"; 142 | } else { 143 | szInfo = "local configuration failed!"; 144 | } 145 | showOPInfo(szInfo); 146 | } 147 | 148 | // windows number 149 | function changeWndNum(iType) { 150 | iType = parseInt(iType, 10); 151 | WebVideoCtrl.I_ChangeWndNum(iType); 152 | } 153 | 154 | // login 155 | function clickLogin() { 156 | var szIP = $("#loginip").val(), 157 | szPort = $("#port").val(), 158 | szUsername = $("#username").val(), 159 | szPassword = $("#password").val(); 160 | 161 | if ("" == szIP || "" == szPort) { 162 | return; 163 | } 164 | 165 | var iRet = WebVideoCtrl.I_Login(szIP, 1, szPort, szUsername, szPassword, { 166 | success: function (xmlDoc) { 167 | showOPInfo(szIP + " login success!"); 168 | 169 | $("#ip").prepend(""); 170 | setTimeout(function () { 171 | $("#ip").val(szIP); 172 | getChannelInfo(); 173 | }, 10); 174 | }, 175 | error: function () { 176 | showOPInfo(szIP + " login failed!"); 177 | } 178 | }); 179 | 180 | if (-1 == iRet) { 181 | showOPInfo(szIP + " login already !"); 182 | } 183 | } 184 | 185 | // exit 186 | function clickLogout() { 187 | var szIP = $("#ip").val(), 188 | szInfo = ""; 189 | 190 | if (szIP == "") { 191 | return; 192 | } 193 | 194 | var iRet = WebVideoCtrl.I_Logout(szIP); 195 | if (0 == iRet) { 196 | szInfo = "exit success!"; 197 | 198 | $("#ip option[value='" + szIP + "']").remove(); 199 | getChannelInfo(); 200 | } else { 201 | szInfo = "exit failed!"; 202 | } 203 | showOPInfo(szIP + " " + szInfo); 204 | } 205 | 206 | // get deivce info 207 | function clickGetDeviceInfo() { 208 | var szIP = $("#ip").val(); 209 | 210 | if ("" == szIP) { 211 | return; 212 | } 213 | 214 | WebVideoCtrl.I_GetDeviceInfo(szIP, { 215 | success: function (xmlDoc) { 216 | var arrStr = []; 217 | arrStr.push("device name:" + $(xmlDoc).find("deviceName").eq(0).text() + "\r\n"); 218 | arrStr.push("device ID:" + $(xmlDoc).find("deviceID").eq(0).text() + "\r\n"); 219 | arrStr.push("model:" + $(xmlDoc).find("model").eq(0).text() + "\r\n"); 220 | arrStr.push("serial number:" + $(xmlDoc).find("serialNumber").eq(0).text() + "\r\n"); 221 | arrStr.push("MAC address:" + $(xmlDoc).find("macAddress").eq(0).text() + "\r\n"); 222 | arrStr.push("firmware version:" + $(xmlDoc).find("firmwareVersion").eq(0).text() + " " + $(xmlDoc).find("firmwareReleasedDate").eq(0).text() + "\r\n"); 223 | arrStr.push("encoder version:" + $(xmlDoc).find("encoderVersion").eq(0).text() + " " + $(xmlDoc).find("encoderReleasedDate").eq(0).text() + "\r\n"); 224 | 225 | showOPInfo(szIP + " get deivce info success!"); 226 | alert(arrStr.join("")); 227 | }, 228 | error: function () { 229 | showOPInfo(szIP + " get device info failed!"); 230 | } 231 | }); 232 | } 233 | 234 | // get channel info 235 | function getChannelInfo() { 236 | var szIP = $("#ip").val(), 237 | oSel = $("#channels").empty(), 238 | nAnalogChannel = 0; 239 | 240 | if ("" == szIP) { 241 | return; 242 | } 243 | 244 | // analog channel 245 | WebVideoCtrl.I_GetAnalogChannelInfo(szIP, { 246 | async: false, 247 | success: function (xmlDoc) { 248 | var oChannels = $(xmlDoc).find("VideoInputChannel"); 249 | nAnalogChannel = oChannels.length; 250 | 251 | $.each(oChannels, function (i) { 252 | var id = parseInt($(this).find("id").eq(0).text(), 10), 253 | name = $(this).find("name").eq(0).text(); 254 | if ("" == name) { 255 | name = "Camera " + (id < 9 ? "0" + id : id); 256 | } 257 | oSel.append(""); 258 | }); 259 | showOPInfo(szIP + " get analog channel success!"); 260 | }, 261 | error: function () { 262 | showOPInfo(szIP + " get analog channel failed!"); 263 | } 264 | }); 265 | // IP channel 266 | WebVideoCtrl.I_GetDigitalChannelInfo(szIP, { 267 | async: false, 268 | success: function (xmlDoc) { 269 | var oChannels = $(xmlDoc).find("InputProxyChannelStatus"); 270 | 271 | $.each(oChannels, function (i) { 272 | var id = parseInt($(this).find("id").eq(0).text(), 10), 273 | name = $(this).find("name").eq(0).text(), 274 | online = $(this).find("online").eq(0).text(); 275 | if ("false" == online) {// filter the forbidden IP channel 276 | return true; 277 | } 278 | if ("" == name) { 279 | name = "IPCamera " + ((id - nAnalogChannel) < 9 ? "0" + (id - nAnalogChannel) : (id - nAnalogChannel)); 280 | } 281 | oSel.append(""); 282 | }); 283 | showOPInfo(szIP + " get IP channel success!"); 284 | }, 285 | error: function () { 286 | showOPInfo(szIP + " get IP channel failed!"); 287 | } 288 | }); 289 | // zero-channel info 290 | WebVideoCtrl.I_GetZeroChannelInfo(szIP, { 291 | async: false, 292 | success: function (xmlDoc) { 293 | var oChannels = $(xmlDoc).find("ZeroVideoChannel"); 294 | 295 | $.each(oChannels, function (i) { 296 | var id = parseInt($(this).find("id").eq(0).text(), 10), 297 | name = $(this).find("name").eq(0).text(); 298 | if ("" == name) { 299 | name = "Zero Channel " + (id < 9 ? "0" + id : id); 300 | } 301 | if ("true" == $(this).find("enabled").eq(0).text()) {// filter the forbidden zero-channel 302 | oSel.append(""); 303 | } 304 | }); 305 | showOPInfo(szIP + " get zero-channel success!"); 306 | }, 307 | error: function () { 308 | showOPInfo(szIP + " get zero-channel failed!"); 309 | } 310 | }); 311 | } 312 | 313 | // get IP channel 314 | function clickGetDigitalChannelInfo() { 315 | var szIP = $("#ip").val(), 316 | iAnalogChannelNum = 0; 317 | 318 | $("#digitalchannellist").empty(); 319 | 320 | if ("" == szIP) { 321 | return; 322 | } 323 | 324 | // analog channel 325 | WebVideoCtrl.I_GetAnalogChannelInfo(szIP, { 326 | async: false, 327 | success: function (xmlDoc) { 328 | iAnalogChannelNum = $(xmlDoc).find("VideoInputChannel").length; 329 | }, 330 | error: function () { 331 | 332 | } 333 | }); 334 | 335 | // IP channel 336 | WebVideoCtrl.I_GetDigitalChannelInfo(szIP, { 337 | async: false, 338 | success: function (xmlDoc) { 339 | var oChannels = $(xmlDoc).find("InputProxyChannelStatus"), 340 | i = 0; 341 | 342 | $.each(oChannels, function () { 343 | var id = parseInt($(this).find("id").eq(0).text(), 10), 344 | ipAddress = $(this).find("ipAddress").eq(0).text(), 345 | srcInputPort = $(this).find("srcInputPort").eq(0).text(), 346 | managePortNo = $(this).find("managePortNo").eq(0).text(), 347 | online = $(this).find("online").eq(0).text(), 348 | proxyProtocol = $(this).find("proxyProtocol").eq(0).text(); 349 | 350 | var objTr = $("#digitalchannellist").get(0).insertRow(-1); 351 | var objTd = objTr.insertCell(0); 352 | objTd.innerHTML = (id - iAnalogChannelNum) < 10 ? "D0" + (id - iAnalogChannelNum) : "D" + (id - iAnalogChannelNum); 353 | objTd = objTr.insertCell(1); 354 | objTd.width = "25%"; 355 | objTd.innerHTML = ipAddress; 356 | objTd = objTr.insertCell(2); 357 | objTd.width = "15%"; 358 | objTd.innerHTML = srcInputPort; 359 | objTd = objTr.insertCell(3); 360 | objTd.width = "20%"; 361 | objTd.innerHTML = managePortNo; 362 | objTd = objTr.insertCell(4); 363 | objTd.width = "15%"; 364 | objTd.innerHTML = "true" == online ? "online" : "offline"; 365 | objTd = objTr.insertCell(5); 366 | objTd.width = "25%"; 367 | objTd.innerHTML = proxyProtocol; 368 | }); 369 | showOPInfo(szIP + " get IP channel success!"); 370 | }, 371 | error: function () { 372 | showOPInfo(szIP + " no IP channel!"); 373 | } 374 | }); 375 | } 376 | 377 | // strat real play 378 | function clickStartRealPlay() { 379 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 380 | szIP = $("#ip").val(), 381 | iStreamType = parseInt($("#streamtype").val(), 10), 382 | iChannelID = parseInt($("#channels").val(), 10), 383 | bZeroChannel = $("#channels option").eq($("#channels").get(0).selectedIndex).attr("bZero") == "true" ? true : false, 384 | szInfo = ""; 385 | 386 | if ("" == szIP) { 387 | return; 388 | } 389 | 390 | if (oWndInfo != null) {// stop first 391 | WebVideoCtrl.I_Stop(); 392 | } 393 | 394 | var iRet = WebVideoCtrl.I_StartRealPlay(szIP, { 395 | iStreamType: iStreamType, 396 | iChannelID: iChannelID, 397 | bZeroChannel: bZeroChannel 398 | }); 399 | 400 | if (0 == iRet) { 401 | szInfo = "start real play success!"; 402 | } else { 403 | szInfo = "start real play failed!"; 404 | } 405 | 406 | showOPInfo(szIP + " " + szInfo); 407 | } 408 | 409 | // stop real play 410 | function clickStopRealPlay() { 411 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 412 | szInfo = ""; 413 | 414 | if (oWndInfo != null) { 415 | var iRet = WebVideoCtrl.I_Stop(); 416 | if (0 == iRet) { 417 | szInfo = "stop real play success!"; 418 | } else { 419 | szInfo = "stop real play failed!"; 420 | } 421 | showOPInfo(oWndInfo.szIP + " " + szInfo); 422 | } 423 | } 424 | 425 | // open sound 426 | function clickOpenSound() { 427 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 428 | szInfo = ""; 429 | 430 | if (oWndInfo != null) { 431 | var allWndInfo = WebVideoCtrl.I_GetWindowStatus(); 432 | // close the sound by iterating over all the window 433 | for (var i = 0, iLen = allWndInfo.length; i < iLen; i++) { 434 | oWndInfo = allWndInfo[i]; 435 | if (oWndInfo.bSound) { 436 | WebVideoCtrl.I_CloseSound(oWndInfo.iIndex); 437 | break; 438 | } 439 | } 440 | 441 | var iRet = WebVideoCtrl.I_OpenSound(); 442 | 443 | if (0 == iRet) { 444 | szInfo = "open sound success!"; 445 | } else { 446 | szInfo = "open sound failed!"; 447 | } 448 | showOPInfo(oWndInfo.szIP + " " + szInfo); 449 | } 450 | } 451 | 452 | // close sound 453 | function clickCloseSound() { 454 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 455 | szInfo = ""; 456 | 457 | if (oWndInfo != null) { 458 | var iRet = WebVideoCtrl.I_CloseSound(); 459 | if (0 == iRet) { 460 | szInfo = "close sound success!"; 461 | } else { 462 | szInfo = "close sound failed!"; 463 | } 464 | showOPInfo(oWndInfo.szIP + " " + szInfo); 465 | } 466 | } 467 | 468 | // set volume 469 | function clickSetVolume() { 470 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 471 | iVolume = parseInt($("#volume").val(), 10), 472 | szInfo = ""; 473 | 474 | if (oWndInfo != null) { 475 | var iRet = WebVideoCtrl.I_SetVolume(iVolume); 476 | if (0 == iRet) { 477 | szInfo = "set volume success!"; 478 | } else { 479 | szInfo = "set volume failed!"; 480 | } 481 | showOPInfo(oWndInfo.szIP + " " + szInfo); 482 | } 483 | } 484 | 485 | // capture 486 | function clickCapturePic() { 487 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 488 | szInfo = ""; 489 | 490 | if (oWndInfo != null) { 491 | var szChannelID = $("#channels").val(), 492 | szPicName = oWndInfo.szIP + "_" + szChannelID + "_" + new Date().getTime(), 493 | iRet = WebVideoCtrl.I_CapturePic(szPicName); 494 | if (0 == iRet) { 495 | szInfo = "capture success!"; 496 | } else { 497 | szInfo = "capture failed!"; 498 | } 499 | showOPInfo(oWndInfo.szIP + " " + szInfo); 500 | } 501 | } 502 | 503 | // start record 504 | function clickStartRecord() { 505 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 506 | szInfo = ""; 507 | 508 | if (oWndInfo != null) { 509 | var szChannelID = $("#channels").val(), 510 | szFileName = oWndInfo.szIP + "_" + szChannelID + "_" + new Date().getTime(), 511 | iRet = WebVideoCtrl.I_StartRecord(szFileName); 512 | if (0 == iRet) { 513 | szInfo = "start recording success!"; 514 | } else { 515 | szInfo = "start recording failed!"; 516 | } 517 | showOPInfo(oWndInfo.szIP + " " + szInfo); 518 | } 519 | } 520 | 521 | // stop record 522 | function clickStopRecord() { 523 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 524 | szInfo = ""; 525 | 526 | if (oWndInfo != null) { 527 | var iRet = WebVideoCtrl.I_StopRecord(); 528 | if (0 == iRet) { 529 | szInfo = "stop recording success!"; 530 | } else { 531 | szInfo = "stop recording failed!"; 532 | } 533 | showOPInfo(oWndInfo.szIP + " " + szInfo); 534 | } 535 | } 536 | 537 | // get audio channel 538 | function clickGetAudioInfo() { 539 | var szIP = $("#ip").val(); 540 | 541 | if ("" == szIP) { 542 | return; 543 | } 544 | 545 | WebVideoCtrl.I_GetAudioInfo(szIP, { 546 | success: function (xmlDoc) { 547 | var oAudioChannels = $(xmlDoc).find("TwoWayAudioChannel"), 548 | oSel = $("#audiochannels").empty(); 549 | $.each(oAudioChannels, function () { 550 | var id = $(this).find("id").eq(0).text(); 551 | 552 | oSel.append(""); 553 | }); 554 | showOPInfo(szIP + " get audio channel success!"); 555 | }, 556 | error: function () { 557 | showOPInfo(szIP + " get audio channel failed!"); 558 | } 559 | }); 560 | } 561 | 562 | // start voice talk 563 | function clickStartVoiceTalk() { 564 | var szIP = $("#ip").val(), 565 | iAudioChannel = parseInt($("#audiochannels").val(), 10), 566 | szInfo = ""; 567 | 568 | if ("" == szIP) { 569 | return; 570 | } 571 | 572 | if (isNaN(iAudioChannel)){ 573 | alert("please select channel first!"); 574 | return; 575 | } 576 | 577 | var iRet = WebVideoCtrl.I_StartVoiceTalk(szIP, iAudioChannel); 578 | 579 | if (0 == iRet) { 580 | szInfo = "start voice talk success!"; 581 | } else { 582 | szInfo = "start voice talk failed!"; 583 | } 584 | showOPInfo(szIP + " " + szInfo); 585 | } 586 | 587 | // stop voice talk 588 | function clickStopVoiceTalk() { 589 | var szIP = $("#ip").val(), 590 | iRet = WebVideoCtrl.I_StopVoiceTalk(), 591 | szInfo = ""; 592 | 593 | if ("" == szIP) { 594 | return; 595 | } 596 | 597 | if (0 == iRet) { 598 | szInfo = "stop voice talk success!"; 599 | } else { 600 | szInfo = "stop voice talk failed!"; 601 | } 602 | showOPInfo(szIP + " " + szInfo); 603 | } 604 | 605 | // enable E-zoom 606 | function clickEnableEZoom() { 607 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 608 | szInfo = ""; 609 | 610 | if (oWndInfo != null) { 611 | var iRet = WebVideoCtrl.I_EnableEZoom(); 612 | if (0 == iRet) { 613 | szInfo = "enable E-zoom success!"; 614 | } else { 615 | szInfo = "enable E-zoom failed!"; 616 | } 617 | showOPInfo(oWndInfo.szIP + " " + szInfo); 618 | } 619 | } 620 | 621 | // disable E-zoom 622 | function clickDisableEZoom() { 623 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 624 | szInfo = ""; 625 | 626 | if (oWndInfo != null) { 627 | var iRet = WebVideoCtrl.I_DisableEZoom(); 628 | if (0 == iRet) { 629 | szInfo = "disable E-zoom success!"; 630 | } else { 631 | szInfo = "disable E-zoom failed!"; 632 | } 633 | showOPInfo(oWndInfo.szIP + " " + szInfo); 634 | } 635 | } 636 | 637 | // enable 3D zoom 638 | function clickEnable3DZoom() { 639 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 640 | szInfo = ""; 641 | 642 | if (oWndInfo != null) { 643 | var iRet = WebVideoCtrl.I_Enable3DZoom(); 644 | if (0 == iRet) { 645 | szInfo = "enable 3D zoom success!"; 646 | } else { 647 | szInfo = "enable 3D zoom failed!"; 648 | } 649 | showOPInfo(oWndInfo.szIP + " " + szInfo); 650 | } 651 | } 652 | 653 | // diasble 3D zoom 654 | function clickDisable3DZoom() { 655 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 656 | szInfo = ""; 657 | 658 | if (oWndInfo != null) { 659 | var iRet = WebVideoCtrl.I_Disable3DZoom(); 660 | if (0 == iRet) { 661 | szInfo = "diasble 3D zoom success!"; 662 | } else { 663 | szInfo = "diasble 3D zoom failed!"; 664 | } 665 | showOPInfo(oWndInfo.szIP + " " + szInfo); 666 | } 667 | } 668 | 669 | // full screen 670 | function clickFullScreen() { 671 | WebVideoCtrl.I_FullScreen(true); 672 | } 673 | 674 | // PTZ control, 9- auto; 1,2,3,4,5,6,7,8 - PTZ direction control by mouse 675 | var g_bPTZAuto = false; 676 | function mouseDownPTZControl(iPTZIndex) { 677 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 678 | bZeroChannel = $("#channels option").eq($("#channels").get(0).selectedIndex).attr("bZero") == "true" ? true : false, 679 | iPTZSpeed = $("#ptzspeed").val(), 680 | bStop = false; 681 | 682 | if (bZeroChannel) {// zero-channel does not support PTZ 683 | return; 684 | } 685 | 686 | if (oWndInfo != null) { 687 | if (9 == iPTZIndex && g_bPTZAuto) { 688 | iPTZSpeed = 0;// you can close auto mode by setting speed to 0 when auto is start already 689 | bStop = true; 690 | } else { 691 | g_bPTZAuto = false;// auto mode will be close when you clik other direction 692 | bStop = false; 693 | } 694 | 695 | WebVideoCtrl.I_PTZControl(iPTZIndex, bStop, { 696 | iPTZSpeed: iPTZSpeed, 697 | success: function (xmlDoc) { 698 | if (9 == iPTZIndex) { 699 | g_bPTZAuto = !g_bPTZAuto; 700 | } 701 | showOPInfo(oWndInfo.szIP + " start PTZ success!"); 702 | }, 703 | error: function () { 704 | showOPInfo(oWndInfo.szIP + " start PTZ failed!"); 705 | } 706 | }); 707 | } 708 | } 709 | 710 | // stop PTZ direction 711 | function mouseUpPTZControl() { 712 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex); 713 | 714 | if (oWndInfo != null) { 715 | WebVideoCtrl.I_PTZControl(1, true, { 716 | success: function (xmlDoc) { 717 | showOPInfo(oWndInfo.szIP + " stop PTZ success!"); 718 | }, 719 | error: function () { 720 | showOPInfo(oWndInfo.szIP + " stop PTZ failed!"); 721 | } 722 | }); 723 | } 724 | } 725 | 726 | // set preset 727 | function clickSetPreset() { 728 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 729 | iPresetID = parseInt($("#preset").val(), 10); 730 | 731 | if (oWndInfo != null) { 732 | WebVideoCtrl.I_SetPreset(iPresetID, { 733 | success: function (xmlDoc) { 734 | showOPInfo(oWndInfo.szIP + " set preset success!"); 735 | }, 736 | error: function () { 737 | showOPInfo(oWndInfo.szIP + " set preset failed!"); 738 | } 739 | }); 740 | } 741 | } 742 | 743 | // call preset 744 | function clickGoPreset() { 745 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 746 | iPresetID = parseInt($("#preset").val(), 10); 747 | 748 | if (oWndInfo != null) { 749 | WebVideoCtrl.I_GoPreset(iPresetID, { 750 | success: function (xmlDoc) { 751 | showOPInfo(oWndInfo.szIP + " call preset success!"); 752 | }, 753 | error: function () { 754 | showOPInfo(oWndInfo.szIP + " call preset failed!"); 755 | } 756 | }); 757 | } 758 | } 759 | 760 | // record searching 761 | var iSearchTimes = 0; 762 | function clickRecordSearch(iType) { 763 | var szIP = $("#ip").val(), 764 | iChannelID = $("#channels").val(), 765 | bZeroChannel = $("#channels option").eq($("#channels").get(0).selectedIndex).attr("bZero") == "true" ? true : false, 766 | szStartTime = $("#starttime").val(), 767 | szEndTime = $("#endtime").val(); 768 | 769 | if ("" == szIP) { 770 | return; 771 | } 772 | 773 | if (bZeroChannel) {// zero-channel does not support record searching 774 | return; 775 | } 776 | 777 | if (0 == iType) {// search for the first time 778 | $("#searchlist").empty(); 779 | iSearchTimes = 0; 780 | } 781 | 782 | WebVideoCtrl.I_RecordSearch(szIP, iChannelID, szStartTime, szEndTime, { 783 | iSearchPos: iSearchTimes * 40, 784 | success: function (xmlDoc) { 785 | if("MORE" === $(xmlDoc).find("responseStatusStrg").eq(0).text()) { 786 | 787 | for(var i = 0, nLen = $(xmlDoc).find("searchMatchItem").length; i < nLen; i++) { 788 | var szPlaybackURI = $(xmlDoc).find("playbackURI").eq(i).text(); 789 | if(szPlaybackURI.indexOf("name=") < 0) { 790 | break; 791 | } 792 | var szStartTime = $(xmlDoc).find("startTime").eq(i).text(); 793 | var szEndTime = $(xmlDoc).find("endTime").eq(i).text(); 794 | var szFileName = szPlaybackURI.substring(szPlaybackURI.indexOf("name=") + 5, szPlaybackURI.indexOf("&size=")); 795 | 796 | var objTr = $("#searchlist").get(0).insertRow(-1); 797 | var objTd = objTr.insertCell(0); 798 | objTd.id = "downloadTd" + i; 799 | objTd.innerHTML = iSearchTimes * 40 + (i + 1); 800 | objTd = objTr.insertCell(1); 801 | objTd.width = "30%"; 802 | objTd.innerHTML = szFileName; 803 | objTd = objTr.insertCell(2); 804 | objTd.width = "30%"; 805 | objTd.innerHTML = (szStartTime.replace("T", " ")).replace("Z", ""); 806 | objTd = objTr.insertCell(3); 807 | objTd.width = "30%"; 808 | objTd.innerHTML = (szEndTime.replace("T", " ")).replace("Z", ""); 809 | objTd = objTr.insertCell(4); 810 | objTd.width = "10%"; 811 | objTd.innerHTML = "download"; 812 | $("#downloadTd" + i).data("playbackURI", szPlaybackURI); 813 | } 814 | 815 | iSearchTimes++; 816 | clickRecordSearch(1);// contine to search 817 | } else if ("OK" === $(xmlDoc).find("responseStatusStrg").eq(0).text()) { 818 | var iLength = $(xmlDoc).find("searchMatchItem").length; 819 | for(var i = 0; i < iLength; i++) { 820 | var szPlaybackURI = $(xmlDoc).find("playbackURI").eq(i).text(); 821 | if(szPlaybackURI.indexOf("name=") < 0) { 822 | break; 823 | } 824 | var szStartTime = $(xmlDoc).find("startTime").eq(i).text(); 825 | var szEndTime = $(xmlDoc).find("endTime").eq(i).text(); 826 | var szFileName = szPlaybackURI.substring(szPlaybackURI.indexOf("name=") + 5, szPlaybackURI.indexOf("&size=")); 827 | 828 | var objTr = $("#searchlist").get(0).insertRow(-1); 829 | var objTd = objTr.insertCell(0); 830 | objTd.id = "downloadTd" + i; 831 | objTd.innerHTML = iSearchTimes * 40 + (i + 1); 832 | objTd = objTr.insertCell(1); 833 | objTd.width = "30%"; 834 | objTd.innerHTML = szFileName; 835 | objTd = objTr.insertCell(2); 836 | objTd.width = "30%"; 837 | objTd.innerHTML = (szStartTime.replace("T", " ")).replace("Z", ""); 838 | objTd = objTr.insertCell(3); 839 | objTd.width = "30%"; 840 | objTd.innerHTML = (szEndTime.replace("T", " ")).replace("Z", ""); 841 | objTd = objTr.insertCell(4); 842 | objTd.width = "10%"; 843 | objTd.innerHTML = "download"; 844 | $("#downloadTd" + i).data("playbackURI", szPlaybackURI); 845 | } 846 | showOPInfo(szIP + " search video file success!"); 847 | } else if("NO MATCHES" === $(xmlDoc).find("responseStatusStrg").eq(0).text()) { 848 | setTimeout(function() { 849 | showOPInfo(szIP + " no record file!"); 850 | }, 50); 851 | } 852 | }, 853 | error: function () { 854 | showOPInfo(szIP + " search record file failed!"); 855 | } 856 | }); 857 | } 858 | 859 | // start play back 860 | function clickStartPlayback() { 861 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 862 | szIP = $("#ip").val(), 863 | bZeroChannel = $("#channels option").eq($("#channels").get(0).selectedIndex).attr("bZero") == "true" ? true : false, 864 | iChannelID = $("#channels").val(), 865 | szStartTime = $("#starttime").val(), 866 | szEndTime = $("#endtime").val(), 867 | szInfo = "", 868 | bChecked = $("#transstream").prop("checked"), 869 | iRet = -1; 870 | 871 | if ("" == szIP) { 872 | return; 873 | } 874 | 875 | if (bZeroChannel) {// zero-channel does not support play back 876 | return; 877 | } 878 | 879 | if (oWndInfo != null) {// stop play first 880 | WebVideoCtrl.I_Stop(); 881 | } 882 | 883 | if (bChecked) {// enable transcode playback 884 | var oTransCodeParam = { 885 | TransFrameRate: "16",// 0:full,5:1,6:2,7:4,8:6,9:8,10:10,11:12,12:16,14:15,15:18,13:20,16:22 886 | TransResolution: "2",// 255:Auto,3:4CIF,2:QCIF,1:CIF 887 | TransBitrate: "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 888 | }; 889 | iRet = WebVideoCtrl.I_StartPlayback(szIP, { 890 | iChannelID: iChannelID, 891 | szStartTime: szStartTime, 892 | szEndTime: szEndTime, 893 | oTransCodeParam: oTransCodeParam 894 | }); 895 | } else { 896 | iRet = WebVideoCtrl.I_StartPlayback(szIP, { 897 | iChannelID: iChannelID, 898 | szStartTime: szStartTime, 899 | szEndTime: szEndTime 900 | }); 901 | } 902 | 903 | if (0 == iRet) { 904 | szInfo = "start play back success!"; 905 | } else { 906 | szInfo = "start play back failed!"; 907 | } 908 | showOPInfo(szIP + " " + szInfo); 909 | } 910 | 911 | // stop play back 912 | function clickStopPlayback() { 913 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 914 | szInfo = ""; 915 | 916 | if (oWndInfo != null) { 917 | var iRet = WebVideoCtrl.I_Stop(); 918 | if (0 == iRet) { 919 | szInfo = "stop play back success!"; 920 | } else { 921 | szInfo = "stop play back failed!"; 922 | } 923 | showOPInfo(oWndInfo.szIP + " " + szInfo); 924 | } 925 | } 926 | 927 | // start reverse play 928 | function clickReversePlayback() { 929 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 930 | szIP = $("#ip").val(), 931 | bZeroChannel = $("#channels option").eq($("#channels").get(0).selectedIndex).attr("bZero") == "true" ? true : false, 932 | iChannelID = $("#channels").val(), 933 | szStartTime = $("#starttime").val(), 934 | szEndTime = $("#endtime").val(), 935 | szInfo = ""; 936 | 937 | if ("" == szIP) { 938 | return; 939 | } 940 | 941 | if (bZeroChannel) {// zero-channel does not support reverse play 942 | return; 943 | } 944 | 945 | if (oWndInfo != null) {// stop play first 946 | WebVideoCtrl.I_Stop(); 947 | } 948 | 949 | var iRet = WebVideoCtrl.I_ReversePlayback(szIP, { 950 | iChannelID: iChannelID, 951 | szStartTime: szStartTime, 952 | szEndTime: szEndTime 953 | }); 954 | 955 | if (0 == iRet) { 956 | szInfo = "start reverse play success!"; 957 | } else { 958 | szInfo = "start reverse play failed!"; 959 | } 960 | showOPInfo(szIP + " " + szInfo); 961 | } 962 | 963 | // single frame 964 | function clickFrame() { 965 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 966 | szInfo = ""; 967 | 968 | if (oWndInfo != null) { 969 | var iRet = WebVideoCtrl.I_Frame(); 970 | if (0 == iRet) { 971 | szInfo = "single frame play success!"; 972 | } else { 973 | szInfo = "single frame play failed!"; 974 | } 975 | showOPInfo(oWndInfo.szIP + " " + szInfo); 976 | } 977 | } 978 | 979 | // pause 980 | function clickPause() { 981 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 982 | szInfo = ""; 983 | 984 | if (oWndInfo != null) { 985 | var iRet = WebVideoCtrl.I_Pause(); 986 | if (0 == iRet) { 987 | szInfo = "pause success!"; 988 | } else { 989 | szInfo = "pause failed!"; 990 | } 991 | showOPInfo(oWndInfo.szIP + " " + szInfo); 992 | } 993 | } 994 | 995 | // resume 996 | function clickResume() { 997 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 998 | szInfo = ""; 999 | 1000 | if (oWndInfo != null) { 1001 | var iRet = WebVideoCtrl.I_Resume(); 1002 | if (0 == iRet) { 1003 | szInfo = "resume success!"; 1004 | } else { 1005 | szInfo = "resume failed!"; 1006 | } 1007 | showOPInfo(oWndInfo.szIP + " " + szInfo); 1008 | } 1009 | } 1010 | 1011 | // slow play 1012 | function clickPlaySlow() { 1013 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 1014 | szInfo = ""; 1015 | 1016 | if (oWndInfo != null) { 1017 | var iRet = WebVideoCtrl.I_PlaySlow(); 1018 | if (0 == iRet) { 1019 | szInfo = "slow play success!"; 1020 | } else { 1021 | szInfo = "slow play failed!"; 1022 | } 1023 | showOPInfo(oWndInfo.szIP + " " + szInfo); 1024 | } 1025 | } 1026 | 1027 | // fast play 1028 | function clickPlayFast() { 1029 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex), 1030 | szInfo = ""; 1031 | 1032 | if (oWndInfo != null) { 1033 | var iRet = WebVideoCtrl.I_PlayFast(); 1034 | if (0 == iRet) { 1035 | szInfo = "fast play success!"; 1036 | } else { 1037 | szInfo = "fast play failed!"; 1038 | } 1039 | showOPInfo(oWndInfo.szIP + " " + szInfo); 1040 | } 1041 | } 1042 | 1043 | // OSD time 1044 | function clickGetOSDTime() { 1045 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex); 1046 | 1047 | if (oWndInfo != null) { 1048 | var szTime = WebVideoCtrl.I_GetOSDTime(); 1049 | if (szTime != -1) { 1050 | $("#osdtime").val(szTime); 1051 | showOPInfo(oWndInfo.szIP + " get OSD time success!"); 1052 | } else { 1053 | showOPInfo(oWndInfo.szIP + " get OSD time failed!"); 1054 | } 1055 | } 1056 | } 1057 | 1058 | // download video 1059 | var iDownloadID = -1; 1060 | var tDownloadProcess = 0; 1061 | function clickStartDownloadRecord(i) { 1062 | var szIP = $("#ip").val(), 1063 | szChannelID = $("#channels").val(), 1064 | szFileName = szIP + "_" + szChannelID + "_" + new Date().getTime(), 1065 | szPlaybackURI = $("#downloadTd" + i).data("playbackURI"); 1066 | 1067 | if ("" == szIP) { 1068 | return; 1069 | } 1070 | 1071 | iDownloadID = WebVideoCtrl.I_StartDownloadRecord(szIP, szPlaybackURI, szFileName); 1072 | 1073 | if (iDownloadID < 0) { 1074 | var iErrorValue = WebVideoCtrl.I_GetLastError(); 1075 | if (34 == iErrorValue) { 1076 | showOPInfo(szIP + " download already!"); 1077 | } else if (33 == iErrorValue) { 1078 | showOPInfo(szIP + " lack of space!"); 1079 | } else { 1080 | showOPInfo(szIP + " download failed!"); 1081 | } 1082 | } else { 1083 | $("
").appendTo("body"); 1084 | tDownloadProcess = setInterval("downProcess(" + i + ")", 1000); 1085 | } 1086 | } 1087 | // download process 1088 | function downProcess() { 1089 | var iStatus = WebVideoCtrl.I_GetDownloadStatus(iDownloadID); 1090 | if (0 == iStatus) { 1091 | $("#downProcess").css({ 1092 | width: $("#searchlist").width() + "px", 1093 | height: "100px", 1094 | lineHeight: "100px", 1095 | left: $("#searchlist").offset().left + "px", 1096 | top: $("#searchlist").offset().top + "px" 1097 | }); 1098 | var iProcess = WebVideoCtrl.I_GetDownloadProgress(iDownloadID); 1099 | if (iProcess < 0) { 1100 | clearInterval(tDownloadProcess); 1101 | tDownloadProcess = 0; 1102 | m_iDownloadID = -1; 1103 | } else if (iProcess < 100) { 1104 | $("#downProcess").text(iProcess + "%"); 1105 | } else { 1106 | $("#downProcess").text("100%"); 1107 | setTimeout(function () { 1108 | $("#downProcess").remove(); 1109 | }, 1000); 1110 | 1111 | WebVideoCtrl.I_StopDownloadRecord(iDownloadID); 1112 | 1113 | showOPInfo("video dowload finish"); 1114 | clearInterval(tDownloadProcess); 1115 | tDownloadProcess = 0; 1116 | m_iDownloadID = -1; 1117 | } 1118 | } else { 1119 | WebVideoCtrl.I_StopDownloadRecord(iDownloadID); 1120 | 1121 | clearInterval(tDownloadProcess); 1122 | tDownloadProcess = 0; 1123 | iDownloadID = -1; 1124 | } 1125 | } 1126 | 1127 | // export configuration file 1128 | function clickExportDeviceConfig() { 1129 | var szIP = $("#ip").val(), 1130 | szInfo = ""; 1131 | 1132 | if ("" == szIP) { 1133 | return; 1134 | } 1135 | 1136 | var iRet = WebVideoCtrl.I_ExportDeviceConfig(szIP); 1137 | 1138 | if (0 == iRet) { 1139 | szInfo = " export configuration file success!"; 1140 | } else { 1141 | szInfo = " export configuration file failed!"; 1142 | } 1143 | showOPInfo(szIP + " " + szInfo); 1144 | } 1145 | 1146 | // import configuration file 1147 | function clickImportDeviceConfig() { 1148 | var szIP = $("#ip").val(), 1149 | szFileName = $("#configFile").val(); 1150 | 1151 | if ("" == szIP) { 1152 | return; 1153 | } 1154 | 1155 | if ("" == szFileName) { 1156 | alert("please select configuration file!"); 1157 | return; 1158 | } 1159 | 1160 | var iRet = WebVideoCtrl.I_ImportDeviceConfig(szIP, szFileName); 1161 | 1162 | if (0 == iRet) { 1163 | WebVideoCtrl.I_Restart(szIP, { 1164 | success: function (xmlDoc) { 1165 | $("
reboot...
").appendTo("body"); 1166 | var oSize = getWindowSize(); 1167 | $("#restartDiv").css({ 1168 | width: oSize.width + "px", 1169 | height: oSize.height + "px", 1170 | lineHeight: oSize.height + "px", 1171 | left: 0, 1172 | top: 0 1173 | }); 1174 | setTimeout("reconnect('" + szIP + "')", 20000); 1175 | }, 1176 | error: function () { 1177 | showOPInfo(szIP + " reboot failed!"); 1178 | } 1179 | }); 1180 | } else { 1181 | showOPInfo(szIP + " export failed!"); 1182 | } 1183 | } 1184 | 1185 | // reconnection 1186 | function reconnect(szIP) { 1187 | WebVideoCtrl.I_Reconnect(szIP, { 1188 | success: function (xmlDoc) { 1189 | $("#restartDiv").remove(); 1190 | }, 1191 | error: function () { 1192 | setTimeout(function () {reconnect(szIP);}, 5000); 1193 | } 1194 | }); 1195 | } 1196 | 1197 | // start upgrade 1198 | m_tUpgrade = 0; 1199 | function clickStartUpgrade(szIP) { 1200 | var szIP = $("#ip").val(), 1201 | szFileName = $("#upgradeFile").val(); 1202 | 1203 | if ("" == szIP) { 1204 | return; 1205 | } 1206 | 1207 | if ("" == szFileName) { 1208 | alert("please select upgrade file!"); 1209 | return; 1210 | } 1211 | 1212 | var iRet = WebVideoCtrl.I_StartUpgrade(szIP, szFileName); 1213 | if (0 == iRet) { 1214 | m_tUpgrade = setInterval("getUpgradeStatus('" + szIP + "')", 1000); 1215 | } else { 1216 | showOPInfo(szIP + " upgrade failed!"); 1217 | } 1218 | } 1219 | 1220 | // get upgrade status 1221 | function getUpgradeStatus(szIP) { 1222 | var iStatus = WebVideoCtrl.I_UpgradeStatus(); 1223 | if (iStatus == 0) { 1224 | var iProcess = WebVideoCtrl.I_UpgradeProgress(); 1225 | if (iProcess < 0) { 1226 | clearInterval(m_tUpgrade); 1227 | m_tUpgrade = 0; 1228 | showOPInfo(szIP + " get process failed!"); 1229 | return; 1230 | } else if (iProcess < 100) { 1231 | if (0 == $("#restartDiv").length) { 1232 | $("
").appendTo("body"); 1233 | var oSize = getWindowSize(); 1234 | $("#restartDiv").css({ 1235 | width: oSize.width + "px", 1236 | height: oSize.height + "px", 1237 | lineHeight: oSize.height + "px", 1238 | left: 0, 1239 | top: 0 1240 | }); 1241 | } 1242 | $("#restartDiv").text(iProcess + "%"); 1243 | } else { 1244 | WebVideoCtrl.I_StopUpgrade(); 1245 | clearInterval(m_tUpgrade); 1246 | m_tUpgrade = 0; 1247 | 1248 | $("#restartDiv").remove(); 1249 | 1250 | WebVideoCtrl.I_Restart(szIP, { 1251 | success: function (xmlDoc) { 1252 | $("
reboot...
").appendTo("body"); 1253 | var oSize = getWindowSize(); 1254 | $("#restartDiv").css({ 1255 | width: oSize.width + "px", 1256 | height: oSize.height + "px", 1257 | lineHeight: oSize.height + "px", 1258 | left: 0, 1259 | top: 0 1260 | }); 1261 | setTimeout("reconnect('" + szIP + "')", 20000); 1262 | }, 1263 | error: function () { 1264 | showOPInfo(szIP + " reboot failed!"); 1265 | } 1266 | }); 1267 | } 1268 | } else if (iStatus == 1) { 1269 | WebVideoCtrl.I_StopUpgrade(); 1270 | showOPInfo(szIP + " upgrade failed!"); 1271 | clearInterval(m_tUpgrade); 1272 | m_tUpgrade = 0; 1273 | } else if (iStatus == 2) { 1274 | mWebVideoCtrl.I_StopUpgrade(); 1275 | showOPInfo(szIP + " language does not match!"); 1276 | clearInterval(m_tUpgrade); 1277 | m_tUpgrade = 0; 1278 | } else { 1279 | mWebVideoCtrl.I_StopUpgrade(); 1280 | showOPInfo(szIP + " get status failed!"); 1281 | clearInterval(m_tUpgrade); 1282 | m_tUpgrade = 0; 1283 | } 1284 | } 1285 | 1286 | // check plugin version 1287 | function clickCheckPluginVersion() { 1288 | var iRet = WebVideoCtrl.I_CheckPluginVersion(); 1289 | if (0 == iRet) { 1290 | alert("your plugin version is the latest!"); 1291 | } else { 1292 | alert("detect the latest plugin version!"); 1293 | } 1294 | } 1295 | 1296 | // remote configuration library 1297 | function clickRemoteConfig() { 1298 | var szIP = $("#ip").val(), 1299 | iDevicePort = parseInt($("#deviceport").val(), 10) || "", 1300 | szInfo = ""; 1301 | 1302 | if ("" == szIP) { 1303 | return; 1304 | } 1305 | 1306 | var iRet = WebVideoCtrl.I_RemoteConfig(szIP, { 1307 | iDevicePort: iDevicePort, 1308 | iLan: 0 1309 | }); 1310 | 1311 | if (-1 == iRet) { 1312 | szInfo = "call remote configuration library failed!"; 1313 | } else { 1314 | szInfo = "call remote configuration library success!"; 1315 | } 1316 | showOPInfo(szIP + " " + szInfo); 1317 | } 1318 | 1319 | function clickRestoreDefault() { 1320 | var szIP = $("#ip").val(), 1321 | szMode = "basic"; 1322 | WebVideoCtrl.I_RestoreDefault(szIP, szMode, { 1323 | success: function (xmlDoc) { 1324 | $("#restartDiv").remove(); 1325 | showOPInfo(szIP + " restore default success!"); 1326 | //reboot after restore 1327 | WebVideoCtrl.I_Restart(szIP, { 1328 | success: function (xmlDoc) { 1329 | $("
reboot...
").appendTo("body"); 1330 | var oSize = getWindowSize(); 1331 | $("#restartDiv").css({ 1332 | width: oSize.width + "px", 1333 | height: oSize.height + "px", 1334 | lineHeight: oSize.height + "px", 1335 | left: 0, 1336 | top: 0 1337 | }); 1338 | setTimeout("reconnect('" + szIP + "')", 20000); 1339 | }, 1340 | error: function () { 1341 | showOPInfo(szIP + " reboot failed!"); 1342 | } 1343 | }); 1344 | }, 1345 | error: function () { 1346 | showOPInfo(szIP + " restore default failed!"); 1347 | } 1348 | }); 1349 | } 1350 | 1351 | function PTZZoomIn() { 1352 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex); 1353 | 1354 | if (oWndInfo != null) { 1355 | WebVideoCtrl.I_PTZControl(10, false, { 1356 | iWndIndex: g_iWndIndex, 1357 | success: function (xmlDoc) { 1358 | showOPInfo(oWndInfo.szIP + " Zoom+success!"); 1359 | }, 1360 | error: function () { 1361 | showOPInfo(oWndInfo.szIP + " Zoom+failed!"); 1362 | } 1363 | }); 1364 | } 1365 | } 1366 | 1367 | function PTZZoomout() { 1368 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex); 1369 | 1370 | if (oWndInfo != null) { 1371 | WebVideoCtrl.I_PTZControl(11, false, { 1372 | iWndIndex: g_iWndIndex, 1373 | success: function (xmlDoc) { 1374 | showOPInfo(oWndInfo.szIP + " Zoom-success!"); 1375 | }, 1376 | error: function () { 1377 | showOPInfo(oWndInfo.szIP + " Zoom-failed!"); 1378 | } 1379 | }); 1380 | } 1381 | } 1382 | 1383 | function PTZZoomStop() { 1384 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex); 1385 | 1386 | if (oWndInfo != null) { 1387 | WebVideoCtrl.I_PTZControl(11, true, { 1388 | iWndIndex: g_iWndIndex, 1389 | success: function (xmlDoc) { 1390 | showOPInfo(oWndInfo.szIP + " stop zoom success!"); 1391 | }, 1392 | error: function () { 1393 | showOPInfo(oWndInfo.szIP + " stop zoom failed!"); 1394 | } 1395 | }); 1396 | } 1397 | } 1398 | 1399 | function PTZFocusIn() { 1400 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex); 1401 | 1402 | if (oWndInfo != null) { 1403 | WebVideoCtrl.I_PTZControl(12, false, { 1404 | iWndIndex: g_iWndIndex, 1405 | success: function (xmlDoc) { 1406 | showOPInfo(oWndInfo.szIP + " focus+success!"); 1407 | }, 1408 | error: function () { 1409 | showOPInfo(oWndInfo.szIP + " focus+failed!"); 1410 | } 1411 | }); 1412 | } 1413 | } 1414 | 1415 | function PTZFoucusOut() { 1416 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex); 1417 | 1418 | if (oWndInfo != null) { 1419 | WebVideoCtrl.I_PTZControl(13, false, { 1420 | iWndIndex: g_iWndIndex, 1421 | success: function (xmlDoc) { 1422 | showOPInfo(oWndInfo.szIP + " focus-success!"); 1423 | }, 1424 | error: function () { 1425 | showOPInfo(oWndInfo.szIP + " focus-failed!"); 1426 | } 1427 | }); 1428 | } 1429 | } 1430 | 1431 | function PTZFoucusStop() { 1432 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex); 1433 | 1434 | if (oWndInfo != null) { 1435 | WebVideoCtrl.I_PTZControl(12, true, { 1436 | iWndIndex: g_iWndIndex, 1437 | success: function (xmlDoc) { 1438 | showOPInfo(oWndInfo.szIP + " stop focus success!"); 1439 | }, 1440 | error: function () { 1441 | showOPInfo(oWndInfo.szIP + " stop focus failed!"); 1442 | } 1443 | }); 1444 | } 1445 | } 1446 | 1447 | function PTZIrisIn() { 1448 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex); 1449 | 1450 | if (oWndInfo != null) { 1451 | WebVideoCtrl.I_PTZControl(14, false, { 1452 | iWndIndex: g_iWndIndex, 1453 | success: function (xmlDoc) { 1454 | showOPInfo(oWndInfo.szIP + " Iris+success!"); 1455 | }, 1456 | error: function () { 1457 | showOPInfo(oWndInfo.szIP + " Iris+failed!"); 1458 | } 1459 | }); 1460 | } 1461 | } 1462 | 1463 | function PTZIrisOut() { 1464 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex); 1465 | 1466 | if (oWndInfo != null) { 1467 | WebVideoCtrl.I_PTZControl(15, false, { 1468 | iWndIndex: g_iWndIndex, 1469 | success: function (xmlDoc) { 1470 | showOPInfo(oWndInfo.szIP + " Iris-success!"); 1471 | }, 1472 | error: function () { 1473 | showOPInfo(oWndInfo.szIP + " Iris-failed!"); 1474 | } 1475 | }); 1476 | } 1477 | } 1478 | 1479 | function PTZIrisStop() { 1480 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex); 1481 | 1482 | if (oWndInfo != null) { 1483 | WebVideoCtrl.I_PTZControl(14, true, { 1484 | iWndIndex: g_iWndIndex, 1485 | success: function (xmlDoc) { 1486 | showOPInfo(oWndInfo.szIP + " stop Iris success!"); 1487 | }, 1488 | error: function () { 1489 | showOPInfo(oWndInfo.szIP + " stop Iris failed!"); 1490 | } 1491 | }); 1492 | } 1493 | } 1494 | 1495 | dateFormat = function (oDate, fmt) { 1496 | var o = { 1497 | "M+": oDate.getMonth() + 1, 1498 | "d+": oDate.getDate(), 1499 | "h+": oDate.getHours(), 1500 | "m+": oDate.getMinutes(), 1501 | "s+": oDate.getSeconds(), 1502 | "q+": Math.floor((oDate.getMonth() + 3) / 3), 1503 | "S": oDate.getMilliseconds()//毫秒 1504 | }; 1505 | if(/(y+)/.test(fmt)) { 1506 | fmt = fmt.replace(RegExp.$1, (oDate.getFullYear() + "").substr(4 - RegExp.$1.length)); 1507 | } 1508 | for (var k in o) { 1509 | if(new RegExp("(" + k + ")").test(fmt)) { 1510 | fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); 1511 | } 1512 | } 1513 | return fmt; 1514 | }; 1515 | 1516 | // change mode 1517 | function changeIPMode(iType) { 1518 | var arrPort = [0, 7071, 80]; 1519 | 1520 | $("#serverport").val(arrPort[iType]); 1521 | } 1522 | 1523 | // get device ip 1524 | function clickGetDeviceIP() { 1525 | var iDeviceMode = parseInt($("#devicemode").val(), 10), 1526 | szAddress = $("#serveraddress").val(), 1527 | iPort = parseInt($("#serverport").val(), 10) || 0, 1528 | szDeviceID = $("#deviceid").val(), 1529 | szDeviceInfo = ""; 1530 | 1531 | szDeviceInfo = WebVideoCtrl.I_GetIPInfoByMode(iDeviceMode, szAddress, iPort, szDeviceID); 1532 | 1533 | if ("" == szDeviceInfo) { 1534 | showOPInfo("get device ip failed!"); 1535 | } else { 1536 | showOPInfo("get device ip success!"); 1537 | 1538 | var arrTemp = szDeviceInfo.split("-"); 1539 | $("#loginip").val(arrTemp[0]); 1540 | $("#deviceport").val(arrTemp[1]); 1541 | } 1542 | } -------------------------------------------------------------------------------- /example-loopplay/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | -------------------------------------------------------------------------------- /example-loopplay/index.js: -------------------------------------------------------------------------------- 1 | 2 | // 全局保存当前选中窗口 3 | var g_iWndIndex = 0; //可以不用设置这个变量,有窗口参数的接口中,不用传值,开发包会默认使用当前选择窗口 4 | $(function () { 5 | // 检查插件是否已经安装过 6 | if (-1 == WebVideoCtrl.I_CheckPluginInstall()) { 7 | alert("您还未安装过插件,双击开发包目录里的WebComponents.exe安装!"); 8 | return; 9 | } 10 | 11 | // 初始化插件参数及插入插件 12 | WebVideoCtrl.I_InitPlugin(500, 300, { 13 | iWndowType: 2, 14 | cbSelWnd: function (xmlDoc) { 15 | g_iWndIndex = $(xmlDoc).find("SelectWnd").eq(0).text(); 16 | var szInfo = "当前选择的窗口编号:" + g_iWndIndex; 17 | showOPInfo(szInfo); 18 | } 19 | }); 20 | WebVideoCtrl.I_InsertOBJECTPlugin("divPlugin"); 21 | 22 | // 检查插件是否最新 23 | if (-1 == WebVideoCtrl.I_CheckPluginVersion()) { 24 | alert("检测到新的插件版本,双击开发包目录里的WebComponents.exe升级!"); 25 | return; 26 | } 27 | 28 | // 窗口事件绑定 29 | $(window).bind({ 30 | resize: function () { 31 | var $Restart = $("#restartDiv"); 32 | if ($Restart.length > 0) { 33 | var oSize = getWindowSize(); 34 | $Restart.css({ 35 | width: oSize.width + "px", 36 | height: oSize.height + "px" 37 | }); 38 | } 39 | } 40 | }); 41 | 42 | //初始化日期时间 43 | var szCurTime = dateFormat(new Date(), "yyyy-MM-dd"); 44 | $("#starttime").val(szCurTime + " 00:00:00"); 45 | $("#endtime").val(szCurTime + " 23:59:59"); 46 | 47 | pushSxtMap(); 48 | WebVideoCtrl.I_ChangeWndNum(2); 49 | loginAll(); 50 | }); 51 | 52 | // 登录 53 | function clickLogin(obj) { 54 | var szIP = obj.ip, 55 | szPort = obj.port, 56 | szUsername = obj.username, 57 | szPassword = obj.password; 58 | 59 | if ("" == szIP || "" == szPort) { 60 | return; 61 | } 62 | 63 | var iRet = WebVideoCtrl.I_Login(szIP, 1, szPort, szUsername, szPassword, { 64 | success: function (xmlDoc) { 65 | showOPInfo(szIP + " 登录成功!"); 66 | 67 | loginList.push(szIP); 68 | setTimeout(function () { 69 | getChannelInfo(szIP); 70 | }, 10); 71 | }, 72 | error: function () { 73 | showOPInfo(szIP + " 登录失败!"); 74 | } 75 | }); 76 | 77 | if (-1 == iRet) { 78 | showOPInfo(szIP + " 已登录过!"); 79 | } 80 | } 81 | 82 | // 获取通道 83 | function getChannelInfo(ip) { 84 | var szIP = ip, 85 | //oSel = $("#channels").empty(), 86 | nAnalogChannel = 0; 87 | 88 | if ("" == szIP) { 89 | return; 90 | } 91 | 92 | // 模拟通道 93 | WebVideoCtrl.I_GetAnalogChannelInfo(szIP, { 94 | async: false, 95 | success: function (xmlDoc) { 96 | var oChannels = $(xmlDoc).find("VideoInputChannel"); 97 | nAnalogChannel = oChannels.length; 98 | 99 | $.each(oChannels, function (i) { 100 | var id = parseInt($(this).find("id").eq(0).text(), 10), 101 | name = $(this).find("name").eq(0).text(); 102 | if ("" == name) { 103 | name = "Camera " + (id < 9 ? "0" + id : id); 104 | } 105 | //oSel.append(""); 106 | channelsMap.put(szIP, {"id": id, "bZero": false}); 107 | }); 108 | showOPInfo(szIP + " 获取模拟通道成功!"); 109 | }, 110 | error: function () { 111 | showOPInfo(szIP + " 获取模拟通道失败!"); 112 | } 113 | }); 114 | // 数字通道 115 | WebVideoCtrl.I_GetDigitalChannelInfo(szIP, { 116 | async: false, 117 | success: function (xmlDoc) { 118 | var oChannels = $(xmlDoc).find("InputProxyChannelStatus"); 119 | 120 | $.each(oChannels, function (i) { 121 | var id = parseInt($(this).find("id").eq(0).text(), 10), 122 | name = $(this).find("name").eq(0).text(), 123 | online = $(this).find("online").eq(0).text(); 124 | if ("false" == online) {// 过滤禁用的数字通道 125 | return true; 126 | } 127 | if ("" == name) { 128 | name = "IPCamera " + ((id - nAnalogChannel) < 9 ? "0" + (id - nAnalogChannel) : (id - nAnalogChannel)); 129 | } 130 | //oSel.append(""); 131 | channelsMap.put(szIP, {"id": id, "bZero": false}); 132 | }); 133 | showOPInfo(szIP + " 获取数字通道成功!"); 134 | }, 135 | error: function () { 136 | showOPInfo(szIP + " 获取数字通道失败!"); 137 | } 138 | }); 139 | // 零通道 140 | WebVideoCtrl.I_GetZeroChannelInfo(szIP, { 141 | async: false, 142 | success: function (xmlDoc) { 143 | var oChannels = $(xmlDoc).find("ZeroVideoChannel"); 144 | 145 | $.each(oChannels, function (i) { 146 | var id = parseInt($(this).find("id").eq(0).text(), 10), 147 | name = $(this).find("name").eq(0).text(); 148 | if ("" == name) { 149 | name = "Zero Channel " + (id < 9 ? "0" + id : id); 150 | } 151 | if ("true" == $(this).find("enabled").eq(0).text()) {// 过滤禁用的零通道 152 | //oSel.append(""); 153 | channelsMap.put(szIP, {"id": id, "bZero": true}); 154 | } 155 | }); 156 | showOPInfo(szIP + " 获取零通道成功!"); 157 | }, 158 | error: function () { 159 | showOPInfo(szIP + " 获取零通道失败!"); 160 | } 161 | }); 162 | } 163 | 164 | function pushSxtMap() { 165 | for (var i = 0; i < sxt.length; i++) { 166 | for (var j = 0; j < sxt[i].length; j++) { 167 | cxtMap.put(sxt[i][j].ip, sxt[i][j]); 168 | } 169 | } 170 | } 171 | 172 | // 开始预览 173 | function clickStartRealPlay(ip, windIndex) { 174 | var sxt = cxtMap.get(ip); 175 | var oWndInfo = WebVideoCtrl.I_GetWindowStatus(windIndex), 176 | szIP = sxt.ip, 177 | iStreamType = sxt.streamtype, 178 | iChannelID = channelsMap.get(ip).id, 179 | bZeroChannel = channelsMap.get(ip).bZero, 180 | szInfo = ""; 181 | 182 | if ("" == szIP) { 183 | return; 184 | } 185 | 186 | if (oWndInfo != null) {// 已经在播放了,先停止 187 | showOPInfo("video window: " + windIndex + " 已经在播放了,先停止"); 188 | WebVideoCtrl.I_Stop(windIndex); 189 | } 190 | 191 | var iRet = WebVideoCtrl.I_StartRealPlayToWindow(szIP, { 192 | iStreamType: iStreamType, 193 | iChannelID: iChannelID, 194 | bZeroChannel: bZeroChannel 195 | }, windIndex); 196 | 197 | if (0 == iRet) { 198 | szInfo = "开始预览成功!"; 199 | } else { 200 | szInfo = "开始预览失败!"; 201 | } 202 | 203 | showOPInfo(szIP + " " + szInfo); 204 | } 205 | 206 | function showOPInfo(szInfo) { 207 | //szInfo =dateFormat(new Date(), "yyyy-MM-dd hh:mm:ss") + " " + szInfo; 208 | //console.info(szInfo); 209 | } 210 | 211 | function dateFormat(oDate, fmt) { 212 | var o = { 213 | "M+": oDate.getMonth() + 1, //月份 214 | "d+": oDate.getDate(), //日 215 | "h+": oDate.getHours(), //小时 216 | "m+": oDate.getMinutes(), //分 217 | "s+": oDate.getSeconds(), //秒 218 | "q+": Math.floor((oDate.getMonth() + 3) / 3), //季度 219 | "S": oDate.getMilliseconds()//毫秒 220 | }; 221 | if (/(y+)/.test(fmt)) { 222 | fmt = fmt.replace(RegExp.$1, (oDate.getFullYear() + "").substr(4 - RegExp.$1.length)); 223 | } 224 | for (var k in o) { 225 | if (new RegExp("(" + k + ")").test(fmt)) { 226 | fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); 227 | } 228 | } 229 | return fmt; 230 | } 231 | 232 | var groupId = -1; 233 | function getGroupId() { 234 | groupId++; 235 | if (groupId > sxt.length - 1) { 236 | groupId = 0; 237 | } 238 | return groupId; 239 | } 240 | 241 | function loginAll() { 242 | //clickLogin(sxt[0]); 243 | for (var i = 0; i < sxt.length; i++) { 244 | for (var j = 0; j < sxt[i].length; j++) { 245 | clickLogin(sxt[i][j]); 246 | } 247 | } 248 | } 249 | 250 | var loginList = new Array(); 251 | 252 | var cxtMap = new Map(); 253 | 254 | var channelsMap = new Map(); 255 | 256 | // 播放异常时是否关闭当前窗口前一个播放画面 257 | var errorCloseWindow = true; 258 | 259 | window.setTimeout(startPlay, 2000); 260 | 261 | function startPlay() { 262 | var group_one = sxt[getGroupId()]; 263 | for (var i = 0; i < group_one.length; i++) { 264 | try { 265 | clickStartRealPlay(group_one[i].ip, i + ""); 266 | } catch(e) { 267 | showOPInfo(group_one[i].ip + " 发生异常, 系统将跳过该摄像头, 以及该窗口"); 268 | if (errorCloseWindow) { 269 | WebVideoCtrl.I_Stop( i + ""); 270 | } 271 | } 272 | } 273 | window.setInterval(loopPlay, 30000); 274 | } 275 | 276 | function loopPlay() { 277 | var group = sxt[getGroupId()]; 278 | for (var i = 0; i < group.length; i++) { 279 | try { 280 | clickStartRealPlay(group[i].ip, i + ""); 281 | } catch(e) { 282 | showOPInfo(group[i].ip + " 发生异常, 系统将跳过该摄像头, 以及该窗口"); 283 | if (errorCloseWindow) { 284 | WebVideoCtrl.I_Stop( i + ""); 285 | } 286 | } 287 | } 288 | } 289 | 290 | -------------------------------------------------------------------------------- /example-loopplay/list.js: -------------------------------------------------------------------------------- 1 | var sxt = [[ 2 | { 3 | "ip": "192.168.130.3", 4 | "port": 80, 5 | "username": "admin", 6 | "password": "12345", 7 | "streamtype": 1 8 | },{ 9 | "ip": "192.168.130.7", 10 | "port": 80, 11 | "username": "admin", 12 | "password": "12345", 13 | "streamtype": 1 14 | },{ 15 | "ip": "192.168.130.8", 16 | "port": 80, 17 | "username": "admin", 18 | "password": "12345", 19 | "streamtype": 1 20 | },{ 21 | "ip": "192.168.130.9", 22 | "port": 80, 23 | "username": "admin", 24 | "password": "12345", 25 | "streamtype": 1 26 | } 27 | ],[ 28 | { 29 | "ip": "192.168.130.10", 30 | "port": 80, 31 | "username": "admin", 32 | "password": "12345", 33 | "streamtype": 1 34 | },{ 35 | "ip": "192.168.130.12", 36 | "port": 80, 37 | "username": "admin", 38 | "password": "12345", 39 | "streamtype": 1 40 | },{ 41 | "ip": "192.168.130.14", 42 | "port": 80, 43 | "username": "admin", 44 | "password": "12345", 45 | "streamtype": 1 46 | },{ 47 | "ip": "192.168.130.17", 48 | "port": 80, 49 | "username": "admin", 50 | "password": "12345", 51 | "streamtype": 1 52 | } 53 | ],[ 54 | { 55 | "ip": "192.168.130.18", 56 | "port": 80, 57 | "username": "admin", 58 | "password": "12345", 59 | "streamtype": 1 60 | },{ 61 | "ip": "192.168.130.19", 62 | "port": 80, 63 | "username": "admin", 64 | "password": "12345", 65 | "streamtype": 1 66 | },{ 67 | "ip": "192.168.130.20", 68 | "port": 80, 69 | "username": "admin", 70 | "password": "12345", 71 | "streamtype": 1 72 | },{ 73 | "ip": "192.168.130.22", 74 | "port": 80, 75 | "username": "admin", 76 | "password": "12345", 77 | "streamtype": 1 78 | } 79 | ]]; 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /example-loopplay/map.js: -------------------------------------------------------------------------------- 1 | Array.prototype.remove = function(s) { 2 | for (var i = 0; i < this.length; i++) { 3 | if (s == this[i]) 4 | this.splice(i, 1); 5 | } 6 | } 7 | 8 | /** 9 | * Simple Map 10 | * 11 | * 12 | * var m = new Map(); 13 | * m.put('key','value'); 14 | * ... 15 | * var s = ""; 16 | * m.each(function(key,value,index){ 17 | * s += index+":"+ key+"="+value+"/n"; 18 | * }); 19 | * alert(s); 20 | * 21 | * @author dewitt 22 | * @date 2008-05-24 23 | */ 24 | function Map() { 25 | /** 存放键的数组(遍历用到) */ 26 | this.keys = new Array(); 27 | /** 存放数据 */ 28 | this.data = new Object(); 29 | 30 | /** 31 | * 放入一个键值对 32 | * @param {String} key 33 | * @param {Object} value 34 | */ 35 | this.put = function(key, value) { 36 | if(this.data[key] == null){ 37 | this.keys.push(key); 38 | } 39 | this.data[key] = value; 40 | }; 41 | 42 | /** 43 | * 获取某键对应的值 44 | * @param {String} key 45 | * @return {Object} value 46 | */ 47 | this.get = function(key) { 48 | return this.data[key]; 49 | }; 50 | 51 | /** 52 | * 删除一个键值对 53 | * @param {String} key 54 | */ 55 | this.remove = function(key) { 56 | this.keys.remove(key); 57 | this.data[key] = null; 58 | }; 59 | 60 | /** 61 | * 遍历Map,执行处理函数 62 | * 63 | * @param {Function} 回调函数 function(key,value,index){..} 64 | */ 65 | this.each = function(fn){ 66 | if(typeof fn != 'function'){ 67 | return; 68 | } 69 | var len = this.keys.length; 70 | for(var i=0;i