├── 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 |
42 |
89 |
104 |
184 |
185 |
186 |
245 |
311 |
361 |
384 |
388 |
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="