main.js 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563
  1. // 初始化插件
  2. // 全局保存当前选中窗口
  3. var g_iWndIndex = 0; //可以不用设置这个变量,有窗口参数的接口中,不用传值,开发包会默认使用当前选择窗口
  4. $(function () {
  5. // 检查插件是否已经安装过
  6. if (-1 == WebVideoCtrl.I_CheckPluginInstall()) {
  7. //alert("您还未安装过插件,双击开发包目录里的WebComponents.exe安装!");
  8. play(Player.title, Player.url, 1);
  9. return;
  10. }
  11. // 初始化插件参数及插入插件
  12. WebVideoCtrl.I_InitPlugin(Player.width, 300, {
  13. iWndowType: 2,
  14. cbSelWnd: function (xmlDoc) {
  15. g_iWndIndex = $(xmlDoc).find("SelectWnd").eq(0).text();
  16. var szInfo = "当前选择的窗口编号:" + g_iWndIndex;
  17. showCBInfo(szInfo);
  18. }
  19. });
  20. show(Player.html);
  21. //console.info($("#divPlugin"));
  22. WebVideoCtrl.I_InsertOBJECTPlugin("divPlugin");
  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. var szCurTime = dateFormat(new Date(), "yyyy-MM-dd");
  44. $("#starttime").val(szCurTime + " 00:00:00");
  45. $("#endtime").val(szCurTime + " 23:59:59");
  46. */
  47. clickLogin();
  48. });
  49. // 显示操作信息
  50. function showOPInfo(szInfo) {
  51. szInfo = "<div>" + dateFormat(new Date(), "yyyy-MM-dd hh:mm:ss") + " " + szInfo + "</div>";
  52. //$("#opinfo").html(szInfo + $("#opinfo").html());
  53. }
  54. // 显示回调信息
  55. function showCBInfo(szInfo) {
  56. szInfo = "<div>" + dateFormat(new Date(), "yyyy-MM-dd hh:mm:ss") + " " + szInfo + "</div>";
  57. //$("#cbinfo").html(szInfo + $("#cbinfo").html());
  58. }
  59. // 格式化时间
  60. function dateFormat(oDate, fmt) {
  61. var o = {
  62. "M+": oDate.getMonth() + 1, //月份
  63. "d+": oDate.getDate(), //日
  64. "h+": oDate.getHours(), //小时
  65. "m+": oDate.getMinutes(), //分
  66. "s+": oDate.getSeconds(), //秒
  67. "q+": Math.floor((oDate.getMonth() + 3) / 3), //季度
  68. "S": oDate.getMilliseconds()//毫秒
  69. };
  70. if (/(y+)/.test(fmt)) {
  71. fmt = fmt.replace(RegExp.$1, (oDate.getFullYear() + "").substr(4 - RegExp.$1.length));
  72. }
  73. for (var k in o) {
  74. if (new RegExp("(" + k + ")").test(fmt)) {
  75. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  76. }
  77. }
  78. return fmt;
  79. }
  80. // 获取窗口尺寸
  81. function getWindowSize() {
  82. var nWidth = $(this).width() + $(this).scrollLeft(),
  83. nHeight = $(this).height() + $(this).scrollTop();
  84. return {width: nWidth, height: nHeight};
  85. }
  86. // 打开选择框 0:文件夹 1:文件
  87. function clickOpenFileDlg(id, iType) {
  88. var szDirPath = WebVideoCtrl.I_OpenFileDlg(iType);
  89. if (szDirPath != -1 && szDirPath != "" && szDirPath != null) {
  90. $("#" + id).val(szDirPath);
  91. }
  92. }
  93. // 获取本地参数
  94. function clickGetLocalCfg() {
  95. var xmlDoc = WebVideoCtrl.I_GetLocalCfg();
  96. $("#netsPreach").val($(xmlDoc).find("BuffNumberType").eq(0).text());
  97. $("#wndSize").val($(xmlDoc).find("PlayWndType").eq(0).text());
  98. $("#rulesInfo").val($(xmlDoc).find("IVSMode").eq(0).text());
  99. $("#captureFileFormat").val($(xmlDoc).find("CaptureFileFormat").eq(0).text());
  100. $("#packSize").val($(xmlDoc).find("PackgeSize").eq(0).text());
  101. $("#recordPath").val($(xmlDoc).find("RecordPath").eq(0).text());
  102. $("#downloadPath").val($(xmlDoc).find("DownloadPath").eq(0).text());
  103. $("#previewPicPath").val($(xmlDoc).find("CapturePath").eq(0).text());
  104. $("#playbackPicPath").val($(xmlDoc).find("PlaybackPicPath").eq(0).text());
  105. $("#playbackFilePath").val($(xmlDoc).find("PlaybackFilePath").eq(0).text());
  106. $("#protocolType").val($(xmlDoc).find("ProtocolType").eq(0).text());
  107. showOPInfo("本地配置获取成功!");
  108. }
  109. // 设置本地参数
  110. function clickSetLocalCfg() {
  111. var arrXml = [],
  112. szInfo = "";
  113. arrXml.push("<LocalConfigInfo>");
  114. arrXml.push("<PackgeSize>" + $("#packSize").val() + "</PackgeSize>");
  115. arrXml.push("<PlayWndType>" + $("#wndSize").val() + "</PlayWndType>");
  116. arrXml.push("<BuffNumberType>" + $("#netsPreach").val() + "</BuffNumberType>");
  117. arrXml.push("<RecordPath>" + $("#recordPath").val() + "</RecordPath>");
  118. arrXml.push("<CapturePath>" + $("#previewPicPath").val() + "</CapturePath>");
  119. arrXml.push("<PlaybackFilePath>" + $("#playbackFilePath").val() + "</PlaybackFilePath>");
  120. arrXml.push("<PlaybackPicPath>" + $("#playbackPicPath").val() + "</PlaybackPicPath>");
  121. arrXml.push("<DownloadPath>" + $("#downloadPath").val() + "</DownloadPath>");
  122. arrXml.push("<IVSMode>" + $("#rulesInfo").val() + "</IVSMode>");
  123. arrXml.push("<CaptureFileFormat>" + $("#captureFileFormat").val() + "</CaptureFileFormat>");
  124. arrXml.push("<ProtocolType>" + $("#protocolType").val() + "</ProtocolType>");
  125. arrXml.push("</LocalConfigInfo>");
  126. var iRet = WebVideoCtrl.I_SetLocalCfg(arrXml.join(""));
  127. if (0 == iRet) {
  128. szInfo = "本地配置设置成功!";
  129. } else {
  130. szInfo = "本地配置设置失败!";
  131. }
  132. showOPInfo(szInfo);
  133. }
  134. // 窗口分割数
  135. function changeWndNum(iType) {
  136. iType = parseInt(iType, 10);
  137. WebVideoCtrl.I_ChangeWndNum(iType);
  138. }
  139. // 登录
  140. function clickLogin() {
  141. var szIP = Player.ip,
  142. szPort = Player.port,
  143. szUsername = Player.user,
  144. szPassword = Player.pass;
  145. if ("" == szIP || "" == szPort) {
  146. return;
  147. }
  148. var iRet = WebVideoCtrl.I_Login(szIP, 1, szPort, szUsername, szPassword, {
  149. success: function (xmlDoc) {
  150. showOPInfo(szIP + " 登录成功!");
  151. //clickRemoteConfig();
  152. changeWndNum(1);
  153. clickStartRealPlay();
  154. /*
  155. $("#ip").prepend("<option value='" + szIP + "'>" + szIP + "</option>");
  156. setTimeout(function () {
  157. $("#ip").val(szIP);
  158. getChannelInfo();
  159. }, 10);
  160. */
  161. },
  162. error: function () {
  163. showOPInfo(szIP + " 登录失败!");
  164. }
  165. });
  166. if (-1 == iRet) {
  167. showOPInfo(szIP + " 已登录过!");
  168. }
  169. }
  170. // 退出
  171. function clickLogout() {
  172. var szIP = Player.ip,
  173. szInfo = "";
  174. if (szIP == "") {
  175. return;
  176. }
  177. var iRet = WebVideoCtrl.I_Logout(szIP);
  178. if (0 == iRet) {
  179. szInfo = "退出成功!";
  180. $("#ip option[value='" + szIP + "']").remove();
  181. getChannelInfo();
  182. } else {
  183. szInfo = "退出失败!";
  184. }
  185. showOPInfo(szIP + " " + szInfo);
  186. }
  187. // 获取设备信息
  188. function clickGetDeviceInfo() {
  189. var szIP = Player.ip;
  190. if ("" == szIP) {
  191. return;
  192. }
  193. WebVideoCtrl.I_GetDeviceInfo(szIP, {
  194. success: function (xmlDoc) {
  195. var arrStr = [];
  196. arrStr.push("设备名称:" + $(xmlDoc).find("deviceName").eq(0).text() + "\r\n");
  197. arrStr.push("设备ID:" + $(xmlDoc).find("deviceID").eq(0).text() + "\r\n");
  198. arrStr.push("型号:" + $(xmlDoc).find("model").eq(0).text() + "\r\n");
  199. arrStr.push("设备序列号:" + $(xmlDoc).find("serialNumber").eq(0).text() + "\r\n");
  200. arrStr.push("MAC地址:" + $(xmlDoc).find("macAddress").eq(0).text() + "\r\n");
  201. arrStr.push("主控版本:" + $(xmlDoc).find("firmwareVersion").eq(0).text() + " " + $(xmlDoc).find("firmwareReleasedDate").eq(0).text() + "\r\n");
  202. arrStr.push("编码版本:" + $(xmlDoc).find("encoderVersion").eq(0).text() + " " + $(xmlDoc).find("encoderReleasedDate").eq(0).text() + "\r\n");
  203. showOPInfo(szIP + " 获取设备信息成功!");
  204. alert(arrStr.join(""));
  205. },
  206. error: function () {
  207. showOPInfo(szIP + " 获取设备信息失败!");
  208. }
  209. });
  210. }
  211. // 获取通道
  212. function getChannelInfo() {
  213. var szIP = Player.ip,
  214. oSel = $("#channels").empty(),
  215. nAnalogChannel = 0;
  216. if ("" == szIP) {
  217. return;
  218. }
  219. // 模拟通道
  220. WebVideoCtrl.I_GetAnalogChannelInfo(szIP, {
  221. async: false,
  222. success: function (xmlDoc) {
  223. var oChannels = $(xmlDoc).find("VideoInputChannel");
  224. nAnalogChannel = oChannels.length;
  225. $.each(oChannels, function (i) {
  226. var id = parseInt($(this).find("id").eq(0).text(), 10),
  227. name = $(this).find("name").eq(0).text();
  228. if ("" == name) {
  229. name = "Camera " + (id < 9 ? "0" + id : id);
  230. }
  231. oSel.append("<option value='" + id + "' bZero='false'>" + name + "</option>");
  232. });
  233. showOPInfo(szIP + " 获取模拟通道成功!");
  234. },
  235. error: function () {
  236. showOPInfo(szIP + " 获取模拟通道失败!");
  237. }
  238. });
  239. // 数字通道
  240. WebVideoCtrl.I_GetDigitalChannelInfo(szIP, {
  241. async: false,
  242. success: function (xmlDoc) {
  243. var oChannels = $(xmlDoc).find("InputProxyChannelStatus");
  244. $.each(oChannels, function (i) {
  245. var id = parseInt($(this).find("id").eq(0).text(), 10),
  246. name = $(this).find("name").eq(0).text(),
  247. online = $(this).find("online").eq(0).text();
  248. if ("false" == online) {// 过滤禁用的数字通道
  249. return true;
  250. }
  251. if ("" == name) {
  252. name = "IPCamera " + ((id - nAnalogChannel) < 9 ? "0" + (id - nAnalogChannel) : (id - nAnalogChannel));
  253. }
  254. oSel.append("<option value='" + id + "' bZero='false'>" + name + "</option>");
  255. });
  256. showOPInfo(szIP + " 获取数字通道成功!");
  257. },
  258. error: function () {
  259. showOPInfo(szIP + " 获取数字通道失败!");
  260. }
  261. });
  262. // 零通道
  263. WebVideoCtrl.I_GetZeroChannelInfo(szIP, {
  264. async: false,
  265. success: function (xmlDoc) {
  266. var oChannels = $(xmlDoc).find("ZeroVideoChannel");
  267. $.each(oChannels, function (i) {
  268. var id = parseInt($(this).find("id").eq(0).text(), 10),
  269. name = $(this).find("name").eq(0).text();
  270. if ("" == name) {
  271. name = "Zero Channel " + (id < 9 ? "0" + id : id);
  272. }
  273. if ("true" == $(this).find("enabled").eq(0).text()) {// 过滤禁用的零通道
  274. oSel.append("<option value='" + id + "' bZero='true'>" + name + "</option>");
  275. }
  276. });
  277. showOPInfo(szIP + " 获取零通道成功!");
  278. },
  279. error: function () {
  280. showOPInfo(szIP + " 获取零通道失败!");
  281. }
  282. });
  283. }
  284. // 获取数字通道
  285. function clickGetDigitalChannelInfo() {
  286. var szIP = Player.ip,
  287. iAnalogChannelNum = 0;
  288. $("#digitalchannellist").empty();
  289. if ("" == szIP) {
  290. return;
  291. }
  292. // 模拟通道
  293. WebVideoCtrl.I_GetAnalogChannelInfo(szIP, {
  294. async: false,
  295. success: function (xmlDoc) {
  296. iAnalogChannelNum = $(xmlDoc).find("VideoInputChannel").length;
  297. },
  298. error: function () {
  299. }
  300. });
  301. // 数字通道
  302. WebVideoCtrl.I_GetDigitalChannelInfo(szIP, {
  303. async: false,
  304. success: function (xmlDoc) {
  305. var oChannels = $(xmlDoc).find("InputProxyChannelStatus");
  306. $.each(oChannels, function () {
  307. var id = parseInt($(this).find("id").eq(0).text(), 10),
  308. ipAddress = $(this).find("ipAddress").eq(0).text(),
  309. srcInputPort = $(this).find("srcInputPort").eq(0).text(),
  310. managePortNo = $(this).find("managePortNo").eq(0).text(),
  311. online = $(this).find("online").eq(0).text(),
  312. proxyProtocol = $(this).find("proxyProtocol").eq(0).text();
  313. var objTr = $("#digitalchannellist").get(0).insertRow(-1);
  314. var objTd = objTr.insertCell(0);
  315. objTd.innerHTML = (id - iAnalogChannelNum) < 10 ? "D0" + (id - iAnalogChannelNum) : "D" + (id - iAnalogChannelNum);
  316. objTd = objTr.insertCell(1);
  317. objTd.width = "25%";
  318. objTd.innerHTML = ipAddress;
  319. objTd = objTr.insertCell(2);
  320. objTd.width = "15%";
  321. objTd.innerHTML = srcInputPort;
  322. objTd = objTr.insertCell(3);
  323. objTd.width = "20%";
  324. objTd.innerHTML = managePortNo;
  325. objTd = objTr.insertCell(4);
  326. objTd.width = "15%";
  327. objTd.innerHTML = "true" == online ? "在线" : "离线";
  328. objTd = objTr.insertCell(5);
  329. objTd.width = "25%";
  330. objTd.innerHTML = proxyProtocol;
  331. });
  332. showOPInfo(szIP + " 获取数字通道成功!");
  333. },
  334. error: function () {
  335. showOPInfo(szIP + " 没有数字通道!");
  336. }
  337. });
  338. }
  339. // 开始预览
  340. function clickStartRealPlay() {
  341. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  342. szIP = Player.ip,
  343. iStreamType = 1,
  344. iChannelID = Player.channel,
  345. bZeroChannel = false,
  346. szInfo = "";
  347. if ("" == szIP) {
  348. return;
  349. }
  350. if (oWndInfo != null) {// 已经在播放了,先停止
  351. WebVideoCtrl.I_Stop();
  352. }
  353. var iRet = WebVideoCtrl.I_StartRealPlay(szIP, {
  354. iStreamType: iStreamType,
  355. iChannelID: iChannelID,
  356. bZeroChannel: bZeroChannel
  357. });
  358. if (0 == iRet) {
  359. szInfo = "开始预览成功!";
  360. } else {
  361. szInfo = "开始预览失败!";
  362. }
  363. showOPInfo(szIP + " " + szInfo);
  364. }
  365. // 停止预览
  366. function clickStopRealPlay() {
  367. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  368. szInfo = "";
  369. if (oWndInfo != null) {
  370. var iRet = WebVideoCtrl.I_Stop();
  371. if (0 == iRet) {
  372. szInfo = "停止预览成功!";
  373. } else {
  374. szInfo = "停止预览失败!";
  375. }
  376. showOPInfo(oWndInfo.szIP + " " + szInfo);
  377. }
  378. }
  379. // 打开声音
  380. function clickOpenSound() {
  381. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  382. szInfo = "";
  383. if (oWndInfo != null) {
  384. var allWndInfo = WebVideoCtrl.I_GetWindowStatus();
  385. // 循环遍历所有窗口,如果有窗口打开了声音,先关闭
  386. for (var i = 0, iLen = allWndInfo.length; i < iLen; i++) {
  387. oWndInfo = allWndInfo[i];
  388. if (oWndInfo.bSound) {
  389. WebVideoCtrl.I_CloseSound(oWndInfo.iIndex);
  390. break;
  391. }
  392. }
  393. var iRet = WebVideoCtrl.I_OpenSound();
  394. if (0 == iRet) {
  395. szInfo = "打开声音成功!";
  396. } else {
  397. szInfo = "打开声音失败!";
  398. }
  399. showOPInfo(oWndInfo.szIP + " " + szInfo);
  400. }
  401. }
  402. // 关闭声音
  403. function clickCloseSound() {
  404. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  405. szInfo = "";
  406. if (oWndInfo != null) {
  407. var iRet = WebVideoCtrl.I_CloseSound();
  408. if (0 == iRet) {
  409. szInfo = "关闭声音成功!";
  410. } else {
  411. szInfo = "关闭声音失败!";
  412. }
  413. showOPInfo(oWndInfo.szIP + " " + szInfo);
  414. }
  415. }
  416. // 设置音量
  417. function clickSetVolume() {
  418. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  419. iVolume = parseInt($("#volume").val(), 10),
  420. szInfo = "";
  421. if (oWndInfo != null) {
  422. var iRet = WebVideoCtrl.I_SetVolume(iVolume);
  423. if (0 == iRet) {
  424. szInfo = "音量设置成功!";
  425. } else {
  426. szInfo = "音量设置失败!";
  427. }
  428. showOPInfo(oWndInfo.szIP + " " + szInfo);
  429. }
  430. }
  431. // 抓图
  432. function clickCapturePic() {
  433. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  434. szInfo = "";
  435. if (oWndInfo != null) {
  436. var szChannelID = $("#channels").val(),
  437. szPicName = oWndInfo.szIP + "_" + szChannelID + "_" + new Date().getTime(),
  438. iRet = WebVideoCtrl.I_CapturePic(szPicName);
  439. if (0 == iRet) {
  440. szInfo = "抓图成功!";
  441. } else {
  442. szInfo = "抓图失败!";
  443. }
  444. showOPInfo(oWndInfo.szIP + " " + szInfo);
  445. }
  446. }
  447. // 开始录像
  448. function clickStartRecord() {
  449. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  450. szInfo = "";
  451. if (oWndInfo != null) {
  452. var szChannelID = $("#channels").val(),
  453. szFileName = oWndInfo.szIP + "_" + szChannelID + "_" + new Date().getTime(),
  454. iRet = WebVideoCtrl.I_StartRecord(szFileName);
  455. if (0 == iRet) {
  456. szInfo = "开始录像成功!";
  457. } else {
  458. szInfo = "开始录像失败!";
  459. }
  460. showOPInfo(oWndInfo.szIP + " " + szInfo);
  461. }
  462. }
  463. // 停止录像
  464. function clickStopRecord() {
  465. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  466. szInfo = "";
  467. if (oWndInfo != null) {
  468. var iRet = WebVideoCtrl.I_StopRecord();
  469. if (0 == iRet) {
  470. szInfo = "停止录像成功!";
  471. } else {
  472. szInfo = "停止录像失败!";
  473. }
  474. showOPInfo(oWndInfo.szIP + " " + szInfo);
  475. }
  476. }
  477. // 获取对讲通道
  478. function clickGetAudioInfo() {
  479. var szIP = Player.ip;
  480. if ("" == szIP) {
  481. return;
  482. }
  483. WebVideoCtrl.I_GetAudioInfo(szIP, {
  484. success: function (xmlDoc) {
  485. var oAudioChannels = $(xmlDoc).find("TwoWayAudioChannel"),
  486. oSel = $("#audiochannels").empty();
  487. $.each(oAudioChannels, function () {
  488. var id = $(this).find("id").eq(0).text();
  489. oSel.append("<option value='" + id + "'>" + id + "</option>");
  490. });
  491. showOPInfo(szIP + " 获取对讲通道成功!");
  492. },
  493. error: function () {
  494. showOPInfo(szIP + " 获取对讲通道失败!");
  495. }
  496. });
  497. }
  498. // 开始对讲
  499. function clickStartVoiceTalk() {
  500. var szIP = Player.ip,
  501. iAudioChannel = parseInt($("#audiochannels").val(), 10),
  502. szInfo = "";
  503. if ("" == szIP) {
  504. return;
  505. }
  506. if (isNaN(iAudioChannel)){
  507. alert("请选择对讲通道!");
  508. return;
  509. }
  510. var iRet = WebVideoCtrl.I_StartVoiceTalk(szIP, iAudioChannel);
  511. if (0 == iRet) {
  512. szInfo = "开始对讲成功!";
  513. } else {
  514. szInfo = "开始对讲失败!";
  515. }
  516. showOPInfo(szIP + " " + szInfo);
  517. }
  518. // 停止对讲
  519. function clickStopVoiceTalk() {
  520. var szIP = Player.ip,
  521. iRet = WebVideoCtrl.I_StopVoiceTalk(),
  522. szInfo = "";
  523. if ("" == szIP) {
  524. return;
  525. }
  526. if (0 == iRet) {
  527. szInfo = "停止对讲成功!";
  528. } else {
  529. szInfo = "停止对讲失败!";
  530. }
  531. showOPInfo(szIP + " " + szInfo);
  532. }
  533. // 启用电子放大
  534. function clickEnableEZoom() {
  535. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  536. szInfo = "";
  537. if (oWndInfo != null) {
  538. var iRet = WebVideoCtrl.I_EnableEZoom();
  539. if (0 == iRet) {
  540. szInfo = "启用电子放大成功!";
  541. } else {
  542. szInfo = "启用电子放大失败!";
  543. }
  544. showOPInfo(oWndInfo.szIP + " " + szInfo);
  545. }
  546. }
  547. // 禁用电子放大
  548. function clickDisableEZoom() {
  549. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  550. szInfo = "";
  551. if (oWndInfo != null) {
  552. var iRet = WebVideoCtrl.I_DisableEZoom();
  553. if (0 == iRet) {
  554. szInfo = "禁用电子放大成功!";
  555. } else {
  556. szInfo = "禁用电子放大失败!";
  557. }
  558. showOPInfo(oWndInfo.szIP + " " + szInfo);
  559. }
  560. }
  561. // 启用3D放大
  562. function clickEnable3DZoom() {
  563. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  564. szInfo = "";
  565. if (oWndInfo != null) {
  566. var iRet = WebVideoCtrl.I_Enable3DZoom();
  567. if (0 == iRet) {
  568. szInfo = "启用3D放大成功!";
  569. } else {
  570. szInfo = "启用3D放大失败!";
  571. }
  572. showOPInfo(oWndInfo.szIP + " " + szInfo);
  573. }
  574. }
  575. // 禁用3D放大
  576. function clickDisable3DZoom() {
  577. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  578. szInfo = "";
  579. if (oWndInfo != null) {
  580. var iRet = WebVideoCtrl.I_Disable3DZoom();
  581. if (0 == iRet) {
  582. szInfo = "禁用3D放大成功!";
  583. } else {
  584. szInfo = "禁用3D放大失败!";
  585. }
  586. showOPInfo(oWndInfo.szIP + " " + szInfo);
  587. }
  588. }
  589. // 全屏
  590. function clickFullScreen() {
  591. WebVideoCtrl.I_FullScreen(true);
  592. }
  593. // PTZ控制 9为自动,1,2,3,4,5,6,7,8为方向PTZ
  594. var g_bPTZAuto = false;
  595. function mouseDownPTZControl(iPTZIndex) {
  596. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  597. bZeroChannel = false,
  598. iPTZSpeed = $("#ptzspeed").val(),
  599. bStop = false;
  600. if (bZeroChannel) {// 零通道不支持云台
  601. return;
  602. }
  603. if (oWndInfo != null) {
  604. if (9 == iPTZIndex && g_bPTZAuto) {
  605. iPTZSpeed = 0;// 自动开启后,速度置为0可以关闭自动
  606. bStop = true;
  607. } else {
  608. g_bPTZAuto = false;// 点击其他方向,自动肯定会被关闭
  609. bStop = false;
  610. }
  611. WebVideoCtrl.I_PTZControl(iPTZIndex, bStop, {
  612. iPTZSpeed: iPTZSpeed,
  613. success: function (xmlDoc) {
  614. if (9 == iPTZIndex) {
  615. g_bPTZAuto = !g_bPTZAuto;
  616. }
  617. showOPInfo(oWndInfo.szIP + " 开启云台成功!");
  618. },
  619. error: function () {
  620. showOPInfo(oWndInfo.szIP + " 开启云台失败!");
  621. }
  622. });
  623. }
  624. }
  625. // 方向PTZ停止
  626. function mouseUpPTZControl() {
  627. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);
  628. if (oWndInfo != null) {
  629. WebVideoCtrl.I_PTZControl(1, true, {
  630. success: function (xmlDoc) {
  631. showOPInfo(oWndInfo.szIP + " 停止云台成功!");
  632. },
  633. error: function () {
  634. showOPInfo(oWndInfo.szIP + " 停止云台失败!");
  635. }
  636. });
  637. }
  638. }
  639. // 设置预置点
  640. function clickSetPreset() {
  641. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  642. iPresetID = parseInt($("#preset").val(), 10);
  643. if (oWndInfo != null) {
  644. WebVideoCtrl.I_SetPreset(iPresetID, {
  645. success: function (xmlDoc) {
  646. showOPInfo(oWndInfo.szIP + " 设置预置点成功!");
  647. },
  648. error: function () {
  649. showOPInfo(oWndInfo.szIP + " 设置预置点失败!");
  650. }
  651. });
  652. }
  653. }
  654. // 调用预置点
  655. function clickGoPreset() {
  656. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  657. iPresetID = parseInt($("#preset").val(), 10);
  658. if (oWndInfo != null) {
  659. WebVideoCtrl.I_GoPreset(iPresetID, {
  660. success: function (xmlDoc) {
  661. showOPInfo(oWndInfo.szIP + " 调用预置点成功!");
  662. },
  663. error: function () {
  664. showOPInfo(oWndInfo.szIP + " 调用预置点失败!");
  665. }
  666. });
  667. }
  668. }
  669. // 搜索录像
  670. var iSearchTimes = 0;
  671. function clickRecordSearch(iType) {
  672. var szIP = Player.ip,
  673. iChannelID = $("#channels").val(),
  674. bZeroChannel = false,
  675. szStartTime = $("#starttime").val(),
  676. szEndTime = $("#endtime").val();
  677. if ("" == szIP) {
  678. return;
  679. }
  680. if (bZeroChannel) {// 零通道不支持录像搜索
  681. return;
  682. }
  683. if (0 == iType) {// 首次搜索
  684. $("#searchlist").empty();
  685. iSearchTimes = 0;
  686. }
  687. WebVideoCtrl.I_RecordSearch(szIP, iChannelID, szStartTime, szEndTime, {
  688. iSearchPos: iSearchTimes * 40,
  689. success: function (xmlDoc) {
  690. if("MORE" === $(xmlDoc).find("responseStatusStrg").eq(0).text()) {
  691. for(var i = 0, nLen = $(xmlDoc).find("searchMatchItem").length; i < nLen; i++) {
  692. var szPlaybackURI = $(xmlDoc).find("playbackURI").eq(i).text();
  693. if(szPlaybackURI.indexOf("name=") < 0) {
  694. break;
  695. }
  696. var szStartTime = $(xmlDoc).find("startTime").eq(i).text();
  697. var szEndTime = $(xmlDoc).find("endTime").eq(i).text();
  698. var szFileName = szPlaybackURI.substring(szPlaybackURI.indexOf("name=") + 5, szPlaybackURI.indexOf("&size="));
  699. var objTr = $("#searchlist").get(0).insertRow(-1);
  700. var objTd = objTr.insertCell(0);
  701. objTd.id = "downloadTd" + i;
  702. objTd.innerHTML = iSearchTimes * 40 + (i + 1);
  703. objTd = objTr.insertCell(1);
  704. objTd.width = "30%";
  705. objTd.innerHTML = szFileName;
  706. objTd = objTr.insertCell(2);
  707. objTd.width = "30%";
  708. objTd.innerHTML = (szStartTime.replace("T", " ")).replace("Z", "");
  709. objTd = objTr.insertCell(3);
  710. objTd.width = "30%";
  711. objTd.innerHTML = (szEndTime.replace("T", " ")).replace("Z", "");
  712. objTd = objTr.insertCell(4);
  713. objTd.width = "10%";
  714. objTd.innerHTML = "<a href='javascript:;' onclick='clickStartDownloadRecord(" + i + ");'>下载</a>";
  715. $("#downloadTd" + i).data("playbackURI", szPlaybackURI);
  716. }
  717. iSearchTimes++;
  718. clickRecordSearch(1);// 继续搜索
  719. } else if ("OK" === $(xmlDoc).find("responseStatusStrg").eq(0).text()) {
  720. var iLength = $(xmlDoc).find("searchMatchItem").length;
  721. for(var i = 0; i < iLength; i++) {
  722. var szPlaybackURI = $(xmlDoc).find("playbackURI").eq(i).text();
  723. if(szPlaybackURI.indexOf("name=") < 0) {
  724. break;
  725. }
  726. var szStartTime = $(xmlDoc).find("startTime").eq(i).text();
  727. var szEndTime = $(xmlDoc).find("endTime").eq(i).text();
  728. var szFileName = szPlaybackURI.substring(szPlaybackURI.indexOf("name=") + 5, szPlaybackURI.indexOf("&size="));
  729. var objTr = $("#searchlist").get(0).insertRow(-1);
  730. var objTd = objTr.insertCell(0);
  731. objTd.id = "downloadTd" + i;
  732. objTd.innerHTML = iSearchTimes * 40 + (i + 1);
  733. objTd = objTr.insertCell(1);
  734. objTd.width = "30%";
  735. objTd.innerHTML = szFileName;
  736. objTd = objTr.insertCell(2);
  737. objTd.width = "30%";
  738. objTd.innerHTML = (szStartTime.replace("T", " ")).replace("Z", "");
  739. objTd = objTr.insertCell(3);
  740. objTd.width = "30%";
  741. objTd.innerHTML = (szEndTime.replace("T", " ")).replace("Z", "");
  742. objTd = objTr.insertCell(4);
  743. objTd.width = "10%";
  744. objTd.innerHTML = "<a href='javascript:;' onclick='clickStartDownloadRecord(" + i + ");'>下载</a>";
  745. $("#downloadTd" + i).data("playbackURI", szPlaybackURI);
  746. }
  747. showOPInfo(szIP + " 搜索录像文件成功!");
  748. } else if("NO MATCHES" === $(xmlDoc).find("responseStatusStrg").eq(0).text()) {
  749. setTimeout(function() {
  750. showOPInfo(szIP + " 没有录像文件!");
  751. }, 50);
  752. }
  753. },
  754. error: function () {
  755. showOPInfo(szIP + " 搜索录像文件失败!");
  756. }
  757. });
  758. }
  759. // 开始回放
  760. function clickStartPlayback() {
  761. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  762. szIP = Player.ip,
  763. bZeroChannel = false,
  764. iChannelID = $("#channels").val(),
  765. szStartTime = $("#starttime").val(),
  766. szEndTime = $("#endtime").val(),
  767. szInfo = "",
  768. bChecked = $("#transstream").prop("checked"),
  769. iRet = -1;
  770. if ("" == szIP) {
  771. return;
  772. }
  773. if (bZeroChannel) {// 零通道不支持回放
  774. return;
  775. }
  776. if (oWndInfo != null) {// 已经在播放了,先停止
  777. WebVideoCtrl.I_Stop();
  778. }
  779. if (bChecked) {// 启用转码回放
  780. var oTransCodeParam = {
  781. 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
  782. TransResolution: "2",// 255:Auto,3:4CIF,2:QCIF,1:CIF
  783. 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
  784. };
  785. iRet = WebVideoCtrl.I_StartPlayback(szIP, {
  786. iChannelID: iChannelID,
  787. szStartTime: szStartTime,
  788. szEndTime: szEndTime,
  789. oTransCodeParam: oTransCodeParam
  790. });
  791. } else {
  792. iRet = WebVideoCtrl.I_StartPlayback(szIP, {
  793. iChannelID: iChannelID,
  794. szStartTime: szStartTime,
  795. szEndTime: szEndTime
  796. });
  797. }
  798. if (0 == iRet) {
  799. szInfo = "开始回放成功!";
  800. } else {
  801. szInfo = "开始回放失败!";
  802. }
  803. showOPInfo(szIP + " " + szInfo);
  804. }
  805. // 停止回放
  806. function clickStopPlayback() {
  807. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  808. szInfo = "";
  809. if (oWndInfo != null) {
  810. var iRet = WebVideoCtrl.I_Stop();
  811. if (0 == iRet) {
  812. szInfo = "停止回放成功!";
  813. } else {
  814. szInfo = "停止回放失败!";
  815. }
  816. showOPInfo(oWndInfo.szIP + " " + szInfo);
  817. }
  818. }
  819. // 开始倒放
  820. function clickReversePlayback() {
  821. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  822. szIP = Player.ip,
  823. bZeroChannel = false,
  824. iChannelID = $("#channels").val(),
  825. szStartTime = $("#starttime").val(),
  826. szEndTime = $("#endtime").val(),
  827. szInfo = "";
  828. if ("" == szIP) {
  829. return;
  830. }
  831. if (bZeroChannel) {// 零通道不支持回放
  832. return;
  833. }
  834. if (oWndInfo != null) {// 已经在播放了,先停止
  835. WebVideoCtrl.I_Stop();
  836. }
  837. var iRet = WebVideoCtrl.I_ReversePlayback(szIP, {
  838. iChannelID: iChannelID,
  839. szStartTime: szStartTime,
  840. szEndTime: szEndTime
  841. });
  842. if (0 == iRet) {
  843. szInfo = "开始倒放成功!";
  844. } else {
  845. szInfo = "开始倒放失败!";
  846. }
  847. showOPInfo(szIP + " " + szInfo);
  848. }
  849. // 单帧
  850. function clickFrame() {
  851. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  852. szInfo = "";
  853. if (oWndInfo != null) {
  854. var iRet = WebVideoCtrl.I_Frame();
  855. if (0 == iRet) {
  856. szInfo = "单帧播放成功!";
  857. } else {
  858. szInfo = "单帧播放失败!";
  859. }
  860. showOPInfo(oWndInfo.szIP + " " + szInfo);
  861. }
  862. }
  863. // 暂停
  864. function clickPause() {
  865. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  866. szInfo = "";
  867. if (oWndInfo != null) {
  868. var iRet = WebVideoCtrl.I_Pause();
  869. if (0 == iRet) {
  870. szInfo = "暂停成功!";
  871. } else {
  872. szInfo = "暂停失败!";
  873. }
  874. showOPInfo(oWndInfo.szIP + " " + szInfo);
  875. }
  876. }
  877. // 恢复
  878. function clickResume() {
  879. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  880. szInfo = "";
  881. if (oWndInfo != null) {
  882. var iRet = WebVideoCtrl.I_Resume();
  883. if (0 == iRet) {
  884. szInfo = "恢复成功!";
  885. } else {
  886. szInfo = "恢复失败!";
  887. }
  888. showOPInfo(oWndInfo.szIP + " " + szInfo);
  889. }
  890. }
  891. // 慢放
  892. function clickPlaySlow() {
  893. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  894. szInfo = "";
  895. if (oWndInfo != null) {
  896. var iRet = WebVideoCtrl.I_PlaySlow();
  897. if (0 == iRet) {
  898. szInfo = "慢放成功!";
  899. } else {
  900. szInfo = "慢放失败!";
  901. }
  902. showOPInfo(oWndInfo.szIP + " " + szInfo);
  903. }
  904. }
  905. // 快放
  906. function clickPlayFast() {
  907. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex),
  908. szInfo = "";
  909. if (oWndInfo != null) {
  910. var iRet = WebVideoCtrl.I_PlayFast();
  911. if (0 == iRet) {
  912. szInfo = "快放成功!";
  913. } else {
  914. szInfo = "快放失败!";
  915. }
  916. showOPInfo(oWndInfo.szIP + " " + szInfo);
  917. }
  918. }
  919. // OSD时间
  920. function clickGetOSDTime() {
  921. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);
  922. if (oWndInfo != null) {
  923. var szTime = WebVideoCtrl.I_GetOSDTime();
  924. if (szTime != -1) {
  925. $("#osdtime").val(szTime);
  926. showOPInfo(oWndInfo.szIP + " 获取OSD时间成功!");
  927. } else {
  928. showOPInfo(oWndInfo.szIP + " 获取OSD时间失败!");
  929. }
  930. }
  931. }
  932. // 下载录像
  933. var iDownloadID = -1;
  934. var tDownloadProcess = 0;
  935. function clickStartDownloadRecord(i) {
  936. var szIP = Player.ip,
  937. szChannelID = $("#channels").val(),
  938. szFileName = szIP + "_" + szChannelID + "_" + new Date().getTime(),
  939. szPlaybackURI = $("#downloadTd" + i).data("playbackURI");
  940. if ("" == szIP) {
  941. return;
  942. }
  943. iDownloadID = WebVideoCtrl.I_StartDownloadRecord(szIP, szPlaybackURI, szFileName);
  944. if (iDownloadID < 0) {
  945. var iErrorValue = WebVideoCtrl.I_GetLastError();
  946. if (34 == iErrorValue) {
  947. showOPInfo(szIP + " 已下载!");
  948. } else if (33 == iErrorValue) {
  949. showOPInfo(szIP + " 空间不足!");
  950. } else {
  951. showOPInfo(szIP + " 下载失败!");
  952. }
  953. } else {
  954. $("<div id='downProcess' class='freeze'></div>").appendTo("body");
  955. tDownloadProcess = setInterval("downProcess(" + i + ")", 1000);
  956. }
  957. }
  958. // 下载进度
  959. function downProcess() {
  960. var iStatus = WebVideoCtrl.I_GetDownloadStatus(iDownloadID);
  961. if (0 == iStatus) {
  962. $("#downProcess").css({
  963. width: $("#searchlist").width() + "px",
  964. height: "100px",
  965. lineHeight: "100px",
  966. left: $("#searchlist").offset().left + "px",
  967. top: $("#searchlist").offset().top + "px"
  968. });
  969. var iProcess = WebVideoCtrl.I_GetDownloadProgress(iDownloadID);
  970. if (iProcess < 0) {
  971. clearInterval(tDownloadProcess);
  972. tDownloadProcess = 0;
  973. m_iDownloadID = -1;
  974. } else if (iProcess < 100) {
  975. $("#downProcess").text(iProcess + "%");
  976. } else {
  977. $("#downProcess").text("100%");
  978. setTimeout(function () {
  979. $("#downProcess").remove();
  980. }, 1000);
  981. WebVideoCtrl.I_StopDownloadRecord(iDownloadID);
  982. showOPInfo("录像下载完成");
  983. clearInterval(tDownloadProcess);
  984. tDownloadProcess = 0;
  985. m_iDownloadID = -1;
  986. }
  987. } else {
  988. WebVideoCtrl.I_StopDownloadRecord(iDownloadID);
  989. clearInterval(tDownloadProcess);
  990. tDownloadProcess = 0;
  991. iDownloadID = -1;
  992. }
  993. }
  994. // 导出配置文件
  995. function clickExportDeviceConfig() {
  996. var szIP = Player.ip,
  997. szInfo = "";
  998. if ("" == szIP) {
  999. return;
  1000. }
  1001. var iRet = WebVideoCtrl.I_ExportDeviceConfig(szIP);
  1002. if (0 == iRet) {
  1003. szInfo = "导出配置文件成功!";
  1004. } else {
  1005. szInfo = "导出配置文件失败!";
  1006. }
  1007. showOPInfo(szIP + " " + szInfo);
  1008. }
  1009. // 导入配置文件
  1010. function clickImportDeviceConfig() {
  1011. var szIP = Player.ip,
  1012. szFileName = $("#configFile").val();
  1013. if ("" == szIP) {
  1014. return;
  1015. }
  1016. if ("" == szFileName) {
  1017. alert("请选择配置文件!");
  1018. return;
  1019. }
  1020. var iRet = WebVideoCtrl.I_ImportDeviceConfig(szIP, szFileName);
  1021. if (0 == iRet) {
  1022. WebVideoCtrl.I_Restart(szIP, {
  1023. success: function (xmlDoc) {
  1024. $("<div id='restartDiv' class='freeze'>重启中...</div>").appendTo("body");
  1025. var oSize = getWindowSize();
  1026. $("#restartDiv").css({
  1027. width: oSize.width + "px",
  1028. height: oSize.height + "px",
  1029. lineHeight: oSize.height + "px",
  1030. left: 0,
  1031. top: 0
  1032. });
  1033. setTimeout("reconnect('" + szIP + "')", 20000);
  1034. },
  1035. error: function () {
  1036. showOPInfo(szIP + " 重启失败!");
  1037. }
  1038. });
  1039. } else {
  1040. showOPInfo(szIP + " 导入失败!");
  1041. }
  1042. }
  1043. // 重连
  1044. function reconnect(szIP) {
  1045. WebVideoCtrl.I_Reconnect(szIP, {
  1046. success: function (xmlDoc) {
  1047. $("#restartDiv").remove();
  1048. },
  1049. error: function () {
  1050. setTimeout(function () {reconnect(szIP);}, 5000);
  1051. }
  1052. });
  1053. }
  1054. // 开始升级
  1055. m_tUpgrade = 0;
  1056. function clickStartUpgrade(szIP) {
  1057. var szIP = Player.ip,
  1058. szFileName = $("#upgradeFile").val();
  1059. if ("" == szIP) {
  1060. return;
  1061. }
  1062. if ("" == szFileName) {
  1063. alert("请选择升级文件!");
  1064. return;
  1065. }
  1066. var iRet = WebVideoCtrl.I_StartUpgrade(szIP, szFileName);
  1067. if (0 == iRet) {
  1068. m_tUpgrade = setInterval("getUpgradeStatus('" + szIP + "')", 1000);
  1069. } else {
  1070. showOPInfo(szIP + " 升级失败!");
  1071. }
  1072. }
  1073. // 获取升级状态
  1074. function getUpgradeStatus(szIP) {
  1075. var iStatus = WebVideoCtrl.I_UpgradeStatus();
  1076. if (iStatus == 0) {
  1077. var iProcess = WebVideoCtrl.I_UpgradeProgress();
  1078. if (iProcess < 0) {
  1079. clearInterval(m_tUpgrade);
  1080. m_tUpgrade = 0;
  1081. showOPInfo(szIP + " 获取进度失败!");
  1082. return;
  1083. } else if (iProcess < 100) {
  1084. if (0 == $("#restartDiv").length) {
  1085. $("<div id='restartDiv' class='freeze'></div>").appendTo("body");
  1086. var oSize = getWindowSize();
  1087. $("#restartDiv").css({
  1088. width: oSize.width + "px",
  1089. height: oSize.height + "px",
  1090. lineHeight: oSize.height + "px",
  1091. left: 0,
  1092. top: 0
  1093. });
  1094. }
  1095. $("#restartDiv").text(iProcess + "%");
  1096. } else {
  1097. WebVideoCtrl.I_StopUpgrade();
  1098. clearInterval(m_tUpgrade);
  1099. m_tUpgrade = 0;
  1100. $("#restartDiv").remove();
  1101. WebVideoCtrl.I_Restart(szIP, {
  1102. success: function (xmlDoc) {
  1103. $("<div id='restartDiv' class='freeze'>重启中...</div>").appendTo("body");
  1104. var oSize = getWindowSize();
  1105. $("#restartDiv").css({
  1106. width: oSize.width + "px",
  1107. height: oSize.height + "px",
  1108. lineHeight: oSize.height + "px",
  1109. left: 0,
  1110. top: 0
  1111. });
  1112. setTimeout("reconnect('" + szIP + "')", 20000);
  1113. },
  1114. error: function () {
  1115. showOPInfo(szIP + " 重启失败!");
  1116. }
  1117. });
  1118. }
  1119. } else if (iStatus == 1) {
  1120. WebVideoCtrl.I_StopUpgrade();
  1121. showOPInfo(szIP + " 升级失败!");
  1122. clearInterval(m_tUpgrade);
  1123. m_tUpgrade = 0;
  1124. } else if (iStatus == 2) {
  1125. mWebVideoCtrl.I_StopUpgrade();
  1126. showOPInfo(szIP + " 语言不匹配!");
  1127. clearInterval(m_tUpgrade);
  1128. m_tUpgrade = 0;
  1129. } else {
  1130. mWebVideoCtrl.I_StopUpgrade();
  1131. showOPInfo(szIP + " 获取状态失败!");
  1132. clearInterval(m_tUpgrade);
  1133. m_tUpgrade = 0;
  1134. }
  1135. }
  1136. // 检查插件版本
  1137. function clickCheckPluginVersion() {
  1138. var iRet = WebVideoCtrl.I_CheckPluginVersion();
  1139. if (0 == iRet) {
  1140. alert("您的插件版本已经是最新的!");
  1141. } else {
  1142. alert("检测到新的插件版本!");
  1143. }
  1144. }
  1145. // 远程配置库
  1146. function clickRemoteConfig() {
  1147. var szIP = Player.ip,
  1148. iDevicePort = Player.devicePort,
  1149. szInfo = "";
  1150. if ("" == szIP) {
  1151. return;
  1152. }
  1153. var iRet = WebVideoCtrl.I_RemoteConfig(szIP, {
  1154. iDevicePort: iDevicePort,
  1155. iLan: 1
  1156. });
  1157. if (-1 == iRet) {
  1158. szInfo = "调用远程配置库失败!";
  1159. } else {
  1160. szInfo = "调用远程配置库成功!";
  1161. }
  1162. showOPInfo(szIP + " " + szInfo);
  1163. }
  1164. function clickRestoreDefault() {
  1165. var szIP = Player.ip,
  1166. szMode = "basic";
  1167. WebVideoCtrl.I_RestoreDefault(szIP, szMode, {
  1168. success: function (xmlDoc) {
  1169. $("#restartDiv").remove();
  1170. showOPInfo(szIP + " 恢复默认参数成功!");
  1171. //恢复完成后需要重启
  1172. WebVideoCtrl.I_Restart(szIP, {
  1173. success: function (xmlDoc) {
  1174. $("<div id='restartDiv' class='freeze'>重启中...</div>").appendTo("body");
  1175. var oSize = getWindowSize();
  1176. $("#restartDiv").css({
  1177. width: oSize.width + "px",
  1178. height: oSize.height + "px",
  1179. lineHeight: oSize.height + "px",
  1180. left: 0,
  1181. top: 0
  1182. });
  1183. setTimeout("reconnect('" + szIP + "')", 20000);
  1184. },
  1185. error: function () {
  1186. showOPInfo(szIP + " 重启失败!");
  1187. }
  1188. });
  1189. },
  1190. error: function () {
  1191. showOPInfo(szIP + " 恢复默认参数失败!");
  1192. }
  1193. });
  1194. }
  1195. function PTZZoomIn() {
  1196. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);
  1197. if (oWndInfo != null) {
  1198. WebVideoCtrl.I_PTZControl(10, false, {
  1199. iWndIndex: g_iWndIndex,
  1200. success: function (xmlDoc) {
  1201. showOPInfo(oWndInfo.szIP + " 调焦+成功!");
  1202. },
  1203. error: function () {
  1204. showOPInfo(oWndInfo.szIP + " 调焦+失败!");
  1205. }
  1206. });
  1207. }
  1208. }
  1209. function PTZZoomout() {
  1210. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);
  1211. if (oWndInfo != null) {
  1212. WebVideoCtrl.I_PTZControl(11, false, {
  1213. iWndIndex: g_iWndIndex,
  1214. success: function (xmlDoc) {
  1215. showOPInfo(oWndInfo.szIP + " 调焦-成功!");
  1216. },
  1217. error: function () {
  1218. showOPInfo(oWndInfo.szIP + " 调焦-失败!");
  1219. }
  1220. });
  1221. }
  1222. }
  1223. function PTZZoomStop() {
  1224. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);
  1225. if (oWndInfo != null) {
  1226. WebVideoCtrl.I_PTZControl(11, true, {
  1227. iWndIndex: g_iWndIndex,
  1228. success: function (xmlDoc) {
  1229. showOPInfo(oWndInfo.szIP + " 调焦停止成功!");
  1230. },
  1231. error: function () {
  1232. showOPInfo(oWndInfo.szIP + " 调焦停止失败!");
  1233. }
  1234. });
  1235. }
  1236. }
  1237. function PTZFocusIn() {
  1238. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);
  1239. if (oWndInfo != null) {
  1240. WebVideoCtrl.I_PTZControl(12, false, {
  1241. iWndIndex: g_iWndIndex,
  1242. success: function (xmlDoc) {
  1243. showOPInfo(oWndInfo.szIP + " 聚焦+成功!");
  1244. },
  1245. error: function () {
  1246. showOPInfo(oWndInfo.szIP + " 聚焦+失败!");
  1247. }
  1248. });
  1249. }
  1250. }
  1251. function PTZFoucusOut() {
  1252. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);
  1253. if (oWndInfo != null) {
  1254. WebVideoCtrl.I_PTZControl(13, false, {
  1255. iWndIndex: g_iWndIndex,
  1256. success: function (xmlDoc) {
  1257. showOPInfo(oWndInfo.szIP + " 聚焦-成功!");
  1258. },
  1259. error: function () {
  1260. showOPInfo(oWndInfo.szIP + " 聚焦-失败!");
  1261. }
  1262. });
  1263. }
  1264. }
  1265. function PTZFoucusStop() {
  1266. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);
  1267. if (oWndInfo != null) {
  1268. WebVideoCtrl.I_PTZControl(12, true, {
  1269. iWndIndex: g_iWndIndex,
  1270. success: function (xmlDoc) {
  1271. showOPInfo(oWndInfo.szIP + " 聚焦停止成功!");
  1272. },
  1273. error: function () {
  1274. showOPInfo(oWndInfo.szIP + " 聚焦停止失败!");
  1275. }
  1276. });
  1277. }
  1278. }
  1279. function PTZIrisIn() {
  1280. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);
  1281. if (oWndInfo != null) {
  1282. WebVideoCtrl.I_PTZControl(14, false, {
  1283. iWndIndex: g_iWndIndex,
  1284. success: function (xmlDoc) {
  1285. showOPInfo(oWndInfo.szIP + " 光圈+成功!");
  1286. },
  1287. error: function () {
  1288. showOPInfo(oWndInfo.szIP + " 光圈+失败!");
  1289. }
  1290. });
  1291. }
  1292. }
  1293. function PTZIrisOut() {
  1294. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);
  1295. if (oWndInfo != null) {
  1296. WebVideoCtrl.I_PTZControl(15, false, {
  1297. iWndIndex: g_iWndIndex,
  1298. success: function (xmlDoc) {
  1299. showOPInfo(oWndInfo.szIP + " 光圈-成功!");
  1300. },
  1301. error: function () {
  1302. showOPInfo(oWndInfo.szIP + " 光圈-失败!");
  1303. }
  1304. });
  1305. }
  1306. }
  1307. function PTZIrisStop() {
  1308. var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex);
  1309. if (oWndInfo != null) {
  1310. WebVideoCtrl.I_PTZControl(14, true, {
  1311. iWndIndex: g_iWndIndex,
  1312. success: function (xmlDoc) {
  1313. showOPInfo(oWndInfo.szIP + " 光圈停止成功!");
  1314. },
  1315. error: function () {
  1316. showOPInfo(oWndInfo.szIP + " 光圈停止失败!");
  1317. }
  1318. });
  1319. }
  1320. }
  1321. dateFormat = function (oDate, fmt) {
  1322. var o = {
  1323. "M+": oDate.getMonth() + 1, //月份
  1324. "d+": oDate.getDate(), //日
  1325. "h+": oDate.getHours(), //小时
  1326. "m+": oDate.getMinutes(), //分
  1327. "s+": oDate.getSeconds(), //秒
  1328. "q+": Math.floor((oDate.getMonth() + 3) / 3), //季度
  1329. "S": oDate.getMilliseconds()//毫秒
  1330. };
  1331. if(/(y+)/.test(fmt)) {
  1332. fmt = fmt.replace(RegExp.$1, (oDate.getFullYear() + "").substr(4 - RegExp.$1.length));
  1333. }
  1334. for (var k in o) {
  1335. if(new RegExp("(" + k + ")").test(fmt)) {
  1336. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  1337. }
  1338. }
  1339. return fmt;
  1340. };
  1341. // 切换模式
  1342. function changeIPMode(iType) {
  1343. var arrPort = [0, 7071, 80];
  1344. $("#serverport").val(arrPort[iType]);
  1345. }
  1346. // 获取设备IP
  1347. function clickGetDeviceIP() {
  1348. var iDeviceMode = parseInt($("#devicemode").val(), 10),
  1349. szAddress = $("#serveraddress").val(),
  1350. iPort = parseInt($("#serverport").val(), 10) || 0,
  1351. szDeviceID = $("#deviceid").val(),
  1352. szDeviceInfo = "";
  1353. szDeviceInfo = WebVideoCtrl.I_GetIPInfoByMode(iDeviceMode, szAddress, iPort, szDeviceID);
  1354. if ("" == szDeviceInfo) {
  1355. showOPInfo("设备IP和端口解析失败!");
  1356. } else {
  1357. showOPInfo("设备IP和端口解析成功!");
  1358. var arrTemp = szDeviceInfo.split("-");
  1359. $("#loginip").val(arrTemp[0]);
  1360. $("#deviceport").val(arrTemp[1]);
  1361. }
  1362. }