Closed Skinah closed 3 years ago
You should use customize request to do it, like below:
private View.OnTouchListener onTouchListener = new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if (device != null) {
int action = motionEvent.getAction();
String xml = "";
float x = 0, y = 0, z = 0;
float speed = 1.0f * sbSpeed.getProgress() / sbSpeed.getMax();
int id = view.getId();
if (action == MotionEvent.ACTION_DOWN) {
if (id == R.id.btnUp)
y = speed;
else if (id == R.id.btnDown)
y = -speed;
else if (id == R.id.btnLeft)
x = -speed;
else if (id == R.id.btnRight)
x = speed;
else if (id == R.id.btnZoomin)
z = speed;
else if (id == R.id.btnZoomout)
z = -speed;
xml = String.format("<ContinuousMove xmlns=\"http://www.onvif.org/ver20/ptz/wsdl\">\n" +
"<ProfileToken>Profile_1</ProfileToken>\n" +
"<Velocity>\n" +
" <PanTilt x=\"%3.2f\" y=\"%3.2f\"/>\n" +
" <Zoom x=\"%3.2f\" />\n" +
"</Velocity>\n" +
"<Timeout>PT60S</Timeout>\n" +
"<Speed>\n" +
" <Zoom x=\"%3.2f\"/>\n" +
" <PanTilt x=\"%3.2f\" y=\"%3.2f\" />\n" +
"</Speed>" +
"</ContinuousMove>", x, y, z, speed, speed, speed);
} else if (action == MotionEvent.ACTION_UP) {
xml = "<Stop xmlns=\"http://www.onvif.org/ver20/ptz/wsdl\">\n" +
" <ProfileToken>Profile_1</ProfileToken>\n" +
" <PanTilt>false</PanTilt>\n" +
" <Zoom>false</Zoom>\n" +
"</Stop>";
}
String finalXml = xml;
onvifManager.sendOnvifRequest(device, new OnvifRequest() {
@Override
public String getXml() {
Log.d("RtspClient", finalXml);
return finalXml;
}
@Override
public OnvifType getType() {
return OnvifType.CUSTOM;
}
});
}
return false;
}
};
@kingron 请问有用这个实现过云台控制吗
Hi,
I have PTZ working by extending this lib using external classes so thanks for creating this lib and also making it opensource with a license. Do you plan to update this at all and would you accept any PR that I make to extend its feature set? Any guidance on how I should go about it?
I also need the ability to know the manufacturer and model of auto discovered devices without knowing the user/pass which is possible to do, just not with the lib in its current state.
Wondering what the future plans of this library are as I wish to use the library to give Openhab (a fully opensource home automation platform) better camera support.
Once again thanks and hope to get a reply back as it is sad that Java does not have a fully featured ONVIF library that is actively being added to.