海康视频web完整的海康视频网页播放代码,包含播放,截图,分屏等功能。 /*****实时预览******/
function StartPlayView()
{
var OCXobj = document.getElementById("PlayViewOCX");
strIP = document.getElementById("TextIP").value;
strPort = document.getElementById("TextPort").value;
strName = document.getElementById("TextName").value;
strPwd = document.getElementById("Textpwd").value;
ChanNum = document.getElementById("SelectChan").value;
strXML = "<?xml version='1.0'?><Parament><DeviceIP>" strIP "</DeviceIP><DevicePort>" strPort "</DevicePort><User>" strName "</User><Password>" strPwd "</Password><ChannelNum>" ChanNum "</ChannelNum><ProtocolType>0</ProtocolType><StreamType>0</lStreamType><Transmits></Transmits></Parament>";
OCXobj.StartTask_Preview(strXML);
}
/*****指定窗口实时预览******/
function StartPlayView_InWnd()
{
var OCXobj = document.getElementById("PlayViewOCX");
strIP = document.getElementById("TextIP").value;
strPort = document.getElementById("TextPort").value;
strName = document.getElementById("TextName").value;
strPwd = document.getElementById("Textpwd").value;
ChanNum = document.getElementById("SelectChan").value;
WndIndex = document.getElementById("SelectWnd").value;
strXML = "<?xml version='1.0'?><Parament><DeviceIP>" strIP "</DeviceIP><DevicePort>" strPort "</DevicePort><User>" strName "</User><Password>" strPwd "</Password><ChannelNum>" ChanNum "</ChannelNum><ProtocolType>0</ProtocolType><StreamType>0</lStreamType><Transmits></Transmits></Parament>";
OCXobj.StartTask_Preview_InWnd(strXML,parseInt(WndIndex));
}
/*****空闲窗口实时预览******/
function StartPlayView_Free()
{
var OCXobj = document.getElementById("PlayViewOCX");
strIP = document.getElementById("TextIP").value;
strPort = document.getElementById("TextPort").value;
strName = document.getElementById("TextName").value;
strPwd = document.getElementById("Textpwd").value;
ChanNum = document.getElementById("SelectChan").value;
strXML = "<?xml version='1.0'?><Parament><DeviceIP>" strIP "</DeviceIP><DevicePort>" strPort "</DevicePort><User>" strName "</User><Password>" strPwd "</Password><ChannelNum>" ChanNum "</ChannelNum><ProtocolType>0</ProtocolType><StreamType>0</lStreamType><Transmits></Transmits></Parament>";
OCXobj.StartTask_Preview_FreeWnd(strXML);
}
/*****停止所有预览******/
function StopPlayView()
{
var OCXobj = document.getElementById("PlayViewOCX");
OCXobj.StopAllPreview();
}
/*****设置抓图格式为JPG******/
function CatchPicJPG()
{
var OCXobj = document.getElementById("PlayViewOCX");
OCXobj.SetCapturParam("C:\\pic",0);
}
/*****设置抓图格式为BMP******/
function CatchPicBMP()
{
var OCXobj = document.getElementById("PlayViewOCX");
OCXobj.SetCapturParam("C:\\pic",1);
}
/*****云台:左上******/
function PTZLeftUp()
{
var OCXobj = document.getElementById("PlayViewOCX");
OCXobj.StartTask_PTZ(25,3);
}
/*****云台:上******/
function PTZUp()
{
var OCXobj = document.getElementById("PlayViewOCX");
OCXobj.StartTask_PTZ(21,3);
}
/*****云台:右上******/
function PTZRightUp()
{
var OCXobj = document.getElementById("PlayViewOCX");
OCXobj.StartTask_PTZ(26,3);
}
/*****云台:左******/
function PTZLeft()
{
var OCXobj = document.getElementById("PlayViewOCX");
OCXobj.StartTask_PTZ(23,3);
}
/*****云台:自转******/
function PTZAuto()
{
var OCXobj = document.getElementById("PlayViewOCX");
OCXobj.StartTask_PTZ(29,3);
}
/*****云台:右******/
function PTZRight()
{
var OCXobj = document.getElementById("PlayViewOCX");
OCXobj.StartTask_PTZ(24,3);
}
/*****云台:左下******/
function PTZLeftDown()
{
var OCXobj = document.getElementById("PlayViewOCX");
OCXobj.StartTask_PTZ(27,3);
}
/*****云台:下******/
function PTZDown()
{
var OCXobj = document.getElementById("PlayViewOCX");
OCXobj.StartTask_PTZ(22,3);
}
/*****云台:右下******/
function PTZRightDown()
{
var OCXobj = document.getElementById("PlayViewOCX");
OCXobj.StartTask_PTZ(28,3);
}
/*****云台:停止******/
function PTZStop()
{
var OCXobj = document.getElementById("PlayViewOCX");
OCXobj.StartTask_PTZ(-21,3);
}
/*****云台:焦距 ******/
function PTZAddTimes()
{
var OCXobj = document.getElementById("PlayViewOCX");
OCXobj.StartTask_PTZ(11,3);
}
/*****云台:焦距-******/
function PTZMinusTimes()
{
var OCXobj = document.getElementById("PlayViewOCX");
OCXobj.StartTask_PTZ(12,3);
}
/*****云台:焦点 ******/
function PTZFarFocus()
{
var OCXobj = document.getElementById("PlayViewOCX");
OCXobj.StartTask_PTZ(13,3);
}
/*****云台:焦点-******/
function PTZNearFocus()
{
var OCXobj = document.getElementById("PlayViewOCX");
OCXobj.StartTask_PTZ(14,3);
}
/*****云台:光圈 ******/
function PTZLargeAperture()
{
var OCXobj = document.getElementById("PlayViewOCX");
OCXobj.StartTask_PTZ(15,3);
}
/*****云台:光圈-******/
function PTZSmallAperture()
{
var OCXobj = document.getElementById("PlayViewOCX");
OCXobj.StartTask_PTZ(16,3);
}
/*****云台:调用预置点******/
function GetPt()
{
var OCXobj = document.getElementById("PlayViewOCX");
ptNum = document.getElementById("SelectGetpt").value;
var ret = OCXobj.PTZCtrlGotoPreset(ptNum);
//alert(ret);
}
/*****云台:设置预置点******/
function SetPt()
{
var OCXobj = document.getElementById("PlayViewOCX");
ptNum = document.getElementById("SelectSetpt").value;
//alert(ptNum);
var ret = OCXobj.PTZCtrlSetPreset(parseInt(ptNum));
//alert(ret);
}
/*****获取视频参数******/
function GetVideoEffect()
{
var OCXobj = document.getElementById("PlayViewOCX");
retXML = OCXobj.GetVideoEffect();
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.loadXML(retXML);
document.getElementById("TextBright").value = xmlDoc.documentElement.childNodes[0].childNodes[0].nodeValue;
document.getElementById("TextConstrast").value = xmlDoc.documentElement.childNodes[1].childNodes[0].nodeValue;
document.getElementById("TextSaturation").value = xmlDoc.documentElement.childNodes[2].childNodes[0].nodeValue;
document.getElementById("TextHue").value = xmlDoc.documentElement.childNodes[3].childNodes[0].nodeValue;
}
/*****设置视频参数******/
function SetVideoEffect()
{
var OCXobj = document.getElementById("PlayViewOCX");
BrightValue = document.getElementById("TextBright").value;
ContrastValue = document.getElementById("TextConstrast").value;
SaturationValue = document.getElementById("TextSaturation").value;
HueValue = document.getElementById("TextHue").value;
OCXobj.SetVideoEffect(parseInt(BrightValue),parseInt(ContrastValue),parseInt(SaturationValue),parseInt(HueValue));
}
评论