C++ MFC 通过宇视平台SDK和海康ivms8700平台开发ActiveX控件
程序员文章站
2022-07-05 10:19:30
...
由于公司地图服务里面需要宇视平台和海康ivms8700平台的视频,所以有了这个ActiveX控件。
功能:平台注册、登录、退出、获取组织信息及摄像头信息、视频通道预览、视频通道退出、抓图和录像功能。
点击安装后,安装路径下面有Test ActiveX.html页面,用IE打开可以直接使用。
一、控件在HTML页面上面加载:
以下是HTML调用代码:
<HTML>
<HEAD>
<TITLE>Test ActiveX</TITLE>
</HEAD>
<table>
<tr>
<td>
<object id="HkPlayer1" name="HkPlayer" classid="CLSID:FB9CCAC2-7AA5-4D37-B8A5-96F5F46C87CC" style="width:400px; height:300px;"></object>
<div>
<input type="radio" name ="bType" value="1" onclick="getradio(1);" checked>海康
<input type="radio" name ="bType" value="2" onclick="getradio(2);" >大华
<input type="radio" name ="bType" value="3" onclick="getradio(3);" >宇视科技平台
<input type="radio" name ="bType" value="3" onclick="getradio(4);" >海康IVMS8700平台
</div>
<span>IP:</span><input id="txtIP" type="text" value="10.200.140.10" /><br />
<span>prot:</span><input id="txtPort" type="text" value="8000" /><br />
<span>用户名:</span><input id="txtUserName" type="text" value="admin" /><br />
<span>密码:</span><input id="txtPassword" type="text" value="psl123456" /><br />
<span>通道:</span><input id="txtChannel" type="text" value="1" /><br />
<input id="btnLogin" type="button" value="获取设备信息" onclick="getDevInfo();" />
<input id="btnLogin" type="button" value="注册" onclick="login();" />
<input id="btnLogin" type="button" value="设置登录ID" onclick="SetUserID(1);" />
<input id="btnLogout" type="button" value="注销" onclick="logout();" />
<input id="btnPlay" type="button" value="播放" onclick="startPlay()" />
<input id="btnStop" type="button" value="停止" onclick="stopPlay()" />
<br/>
<input id="btnCapturePicture" type="button" value="抓图" onclick="savePicture()" />
<input id="btnStartCaptureVideo" type="button" value="录像" onclick="startRecordVideo()" />
<input id="btnStopCaptureVideo" type="button" value="停止录像" onclick="stopRecoredVideo()" />
<br/>
<input id="btnLogin" type="button" value="获取平台设备信息" onclick="GetDevInfoPingTai();" />
<input id="btnLogin" type="button" value="平台注册" onclick="LoginPingTai();" />
<input id="btnLogin" type="button" value="设置平台登录ID" onclick="SetUserIDPingTai(1);" />
<input id="btnLogin" type="button" value="海康平台登录ID" onclick="SetUserID(0);" />
<input id="btnLogout" type="button" value="注销" onclick="LogoutPingTai();" />
<input id="btnPlay" type="button" value="平台播放" onclick="StartPlayPingTai()" />
<input id="btnStop" type="button" value="平台停止播放" onclick="StopPlayPingTai()" />
</td>
<td>
<div id="message" style="display:inline;"></div>
</td>
</tr>
</table>
<script type="text/javascript" for="HkPlayer1" event="click()">
alert(this.id);
</script>
<script type="text/javascript" language="javascript" defer="defer">
var activeX = document.getElementById("HkPlayer1");
var stype=1;
var sfile="E:\\";//抓图和视频存放地址
document.getElementById("txtIP").value="10.200.140.10";
document.getElementById("txtPort").value="8000";
document.getElementById("txtUserName").value="admin";
document.getElementById("txtPassword").value="psl123456";
function getradio(i)
{
if(i==1)
{
stype=1;
document.getElementById("txtIP").value="10.200.140.10";
document.getElementById("txtPort").value="8000";
document.getElementById("txtUserName").value="admin";
document.getElementById("txtPassword").value="psl123456";
}
if(i==2)
{
stype=2;
document.getElementById("txtIP").value="192.168.10.11";
document.getElementById("txtPort").value="37777";
document.getElementById("txtUserName").value="admin";
document.getElementById("txtPassword").value="admin";
}
if(i==3)
{
stype=3;
document.getElementById("txtIP").value="192.168.10.212";
document.getElementById("txtPort").value="8800";
document.getElementById("txtUserName").value="wb";
document.getElementById("txtPassword").value="123456";
document.getElementById("txtChannel").value="631f30ca192365465X0";
}
if(i==4)
{
stype=1;
document.getElementById("txtIP").value="172.16.172.117";
document.getElementById("txtPort").value="80";
document.getElementById("txtUserName").value="admin";
document.getElementById("txtPassword").value="Hik12345";
document.getElementById("txtChannel").value="a361677d68af48ceb1f12df19abd3714";
}
}
function SetUserID(i)
{
var r =activeX.SetUserID(i,stype);
addMessage("Login:" + r);
}
function SetUserIDPingTai(i)
{
var r =activeX.SetUserIDPingTai("UserCode","UserLoginCode","UserIpAddress","OrgCode","DomainName","DomainType",stype);
addMessage("Login:" + r);
}
function login() {
var address = txtIP.value;
var port = txtPort.value;
var userName = txtUserName.value;
var password = txtPassword.value;
var r =activeX.Login(address, port, userName, password,stype);
addMessage("Login:" + r);
}
function LoginPingTai() {
var address = txtIP.value;
var port = txtPort.value;
var userName = txtUserName.value;
var password = txtPassword.value;
var r =activeX.LoginPingTai(address, port, userName, password,stype);
addMessage("Login:" + r);
}
function logout() {
var r = activeX.Logout(stype);
addMessage("logout:" + r);
}
function LogoutPingTai() {
var r = activeX.LogoutPingTai(stype);
addMessage("logout:" + r);
}
function startPlay() {
var ch = txtChannel.value;
var r= activeX.StartRealPlay(ch,stype);
addMessage("startPlay:" + r);
}
function StartPlayPingTai() {
var ch = txtChannel.value;
var r= activeX.StartPlayPingTai(ch,stype);
addMessage("startPlay:" + r);
}
function stopPlay() {
var r = activeX.StopRealPlay(stype);
addMessage("stopplay:" + r);
}
function StopPlayPingTai() {
var r = activeX.StopPlayPingTai(stype);
addMessage("stopplay:" + r);
}
function getDevInfo() {
var address = txtIP.value;
var port = txtPort.value;
var userName = txtUserName.value;
var password = txtPassword.value;
var v = activeX.GetDevInfo(address, port, userName, password,stype);
addMessage(v);
}
function GetDevInfoPingTai() {
var address = txtIP.value;
var port = txtPort.value;
var userName = txtUserName.value;
var password = txtPassword.value;
var v = activeX.GetDevInfoPingTai(address, port, userName, password,stype);
addMessage(v);
}
function addMessage(msg) {
var txt = document.getElementById("message").innerHTML;
var d = new Date();
txt += "<br />" + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds() + " " + msg;
document.getElementById("message").innerHTML = txt;
}
function savePicture()
{
var ch = txtChannel.value;
var r = HkPlayer.CapturePicture(sfile,ch,stype);
addMessage("savePicture:" + r);
}
function startRecordVideo() {
var ch = txtChannel.value;
var r = HkPlayer.StartRecord(sfile,ch,stype);
addMessage("startRecordVideo:" + r);
}
function stopRecoredVideo() {
var ch = txtChannel.value;
var r = HkPlayer.StopRecord(ch,stype);
addMessage("stopRecoredVideo:" + r);
}
</script>
</HTML>