2017-05-31 280 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