2017-05-31 181 views
-1

我使用OnVif java库,但它不起作用。如何使用onvif在ip camera中获取rtsp url android

try{ 
    OnvifDevice nvt = new OnvifDevice(cameraIpAddr,cameraUsername,cameraPassword); 
    List<Profile> profiles=nvt.getDevices().getProfiles();   
    String profileToken=profiles.get(0).getToken(); 
    String url= nvt.getMedia().getRTSPStreamUri(profileToken); 
    PtzDevices ptzDevices=nvt.getPtz(); 
    org.onvif.ver10.schema.FloatRange 
    panRange=ptzDevices.getPanSpaces(profileToken); 
    org.onvif.ver10.schema.FloatRange tiltRange= 
    ptzDevices.getTiltSpaces(profileToken); 
    float zoom=ptzDevices.getZoomSpaces(profileToken).getMin(); 
    float x=(panRange.getMax() + panRange.getMin())/2f; 
    float y=(tiltRange.getMax() + tiltRange.getMin())/2f; 
    if(ptzDevices.isAbsoluteMoveSupported(profileToken)){ 
     ptzDevices.absoluteMove(profileToken,x,y,zoom); 
    } 
}catch (ConnectException ex){ 
    ex.printStackTrace(); 
}catch (SOAPException ex){ 
    ex.printStackTrace(); 
} 

在Android Studio中,SOAPException类未找到,我使用的外部jar的gradle却未能打造添加类的SoapException请给我对Java和Android onvif client例如然后通知我。

请给我参考了网上使用的Android

+0

请检查我的回答得到RTSP URL。 –

回答

0

请试试这个

dependencies { 
    compile files('libs/yourfilename.jar') 
} 
+0

我已经使用这个依赖 – Alpesh

+0

OnvifDevice nvt = new OnvifDevice(cameraIpAddr,cameraUsername,cameraPassword); 总是崩溃的应用程序。 – Alpesh