基於海康威視SDK javaB/S


基於海康威視SDK javaB/S 下載NetVideoActiveX23.cab文件,放在webRoot下面的codebase文件夾里 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> //全局變量定義 var m_iNowChanNo = -1; //當前通道號 var m_iLoginUserId = -1; //注冊設備用戶ID var m_iChannelNum = -1; //模擬通道總數 var m_bDVRControl = null; //OCX控件對象 var m_iProtocolType = 0; //協議類型,0 – TCP, 1 - UDP var m_iStreamType = 0; //碼流類型,0 表示主碼流, 1 表示子碼流 var m_iPlay = 0; //當前是否正在預覽 var m_iRecord = 0; //當前是否正在錄像 var m_iTalk = 0; //當前是否正在對講 var m_iVoice = 0; //當前是否打開聲音 var m_iAutoPTZ = 0; //當前雲台是否正在自轉 var m_iPTZSpeed = 4; //雲台速度 /************************************************* Function: LogMessage Description: 寫執行結果日志 Input: msg:日志 Output: 無 Return: 無 *************************************************/ function LogMessage(msg) { //var myDate = new Date(); //var szNowTime = myDate.toLocaleString( ); //獲取日期與時間 document.getElementById("OperatLogBody").innerHTML = "--> " + msg; } /************************************************* Function: onload Description: 頁面加載完后判斷系統日期是否在1971-2037范圍 Input: 無 Output: 無 Return: 無 *************************************************/ window.onload = function () { function getIP() { var obj = bzmis.vidio_index2.getIP(); return obj.value; } function getPort() { var obj = bzmis.vidio_index2.getPort(); return obj.value; } function getUserName() { var obj = bzmis.vidio_index2.getUserName(); return obj.value; } function getPassword() { var obj = bzmis.vidio_index2.getPassword(); return obj.value; } function getChannelNo() { var obj = bzmis.vidio_index2.getChannelNo(); return obj.value; } var myDate = new Date(); var iYear = myDate.getFullYear(); if (iYear < 1971 || iYear > 2037) { alert("為了正常使用本軟件,請將系統日期年限設置在1971-2037范圍內!"); //parent.location.href = "../login.php"; } if (document.getElementById("HIKOBJECT1").object == null) { alert("請先下載控件並注冊!"); m_bDVRControl = null; } else { m_bDVRControl = document.getElementById("HIKOBJECT1"); ChangeStatus(1); // ArrangeWindow(1); } var szDevIp = '192.168.32.31'; var szDevPort = '8000'; var szDevUser = 'admin'; var szDevPwd = '12345'; m_iLoginUserId = m_bDVRControl.Login(szDevIp, szDevPort, szDevUser, szDevPwd); if (m_iLoginUserId == -1) { LogMessage("注冊失敗!"); } else { LogMessage("注冊成功!"); } m_iNowChanNo = 3; if (m_iNowChanNo > -1) { if (m_iPlay == 1) { m_bDVRControl.StopRealPlay(); } var bRet = m_bDVRControl.StartRealPlay(m_iNowChanNo, m_iProtocolType, m_iStreamType); if (bRet) { LogMessage("預覽通道" + (m_iNowChanNo + 1) + "成功!"); m_iPlay = 1; } else { LogMessage("預覽通道" + (m_iNowChanNo + 1) + "失敗!"); } } } /************************************************* Function: ChangeStatus Description: 選中窗口時,相應通道的狀態顯示 Input: iWindowNum : 選中窗口號 Output: 無 return: 無 *************************************************/ function ChangeStatus(iWindowNum) { m_bDVRControl = document.getElementById("HIKOBJECT" + iWindowNum); /*for(var i = 1; i <= 4; i ++) { if(i == iWindowNum) { document.getElementById("NetPlayOCX" + i).style.border = "1px solid #00F"; } else { document.getElementById("NetPlayOCX" + i).style.border = "1px solid #EBEBEB"; } } LogMessage("當前選中窗口" + iWindowNum); */ } //document.oncontextmenu = rightclick; /************************************************* Function: rightclick Description: 網頁禁用右鍵 Input: 無 Output: 無 Return: bool: true false *************************************************/ function rightclick() { return false; } function workaround() { window.document.all.item("ocx").style.display = "none"; window.document.all.item("ocx").style.display = ""; document.getElementById("HIKOBJECT1").width = document.body.clientWidth; document.getElementById("HIKOBJECT1").height = document.body.clientHeight; } //關閉資源,退出登錄 function ExitApp() { m_bDVRControl = document.getElementById("HIKOBJECT1"); this.m_bDVRControl.Logout(); }
//document.activex.url.value="https://192.0.7.213" //OCXobj.SendCmd(); //OCXobj.NumBig();


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM