| | |
| | | package com.basic.security.utils; |
| | | |
| | | import com.basic.security.manager.SettingManager; |
| | | import com.basic.security.model.Alarm; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.JsonArray; |
| | |
| | | import java.util.Map; |
| | | |
| | | public class VideoPath { |
| | | static Gson gson = new Gson(); |
| | | |
| | | public static String getVideoUrl(Map<String, String> alarm) { |
| | | String videoUrl = ""; |
| | | String Server = SettingManager.getIpStr(); |
| | | String Port = "6000"; |
| | | String base_url = "http://" + Server + ":" + Port + "/basic/api/androidAlarm/es/"; |
| | | |
| | | try { |
| | | String base_url = "192.168.20.10:6000/basic/api/androidAlarm/es/"; |
| | | String alarmId = alarm.get(Alarm.id); |
| | | |
| | | URL url = new URL(base_url+alarmId); |
| | |
| | | InputStream in = new BufferedInputStream(conn.getInputStream()); |
| | | String response = org.apache.commons.io.IOUtils.toString(in, "UTF-8"); |
| | | |
| | | System.out.println("videoUrl response :" + response); |
| | | // System.out.println("videoUrl response :" + response); |
| | | boolean isJSON = true; |
| | | JsonParser parser = new JsonParser(); |
| | | JsonElement element = null; |
| | | try { |
| | | element = parser.parse(response); |
| | | } catch (JsonParseException e) { |
| | | System.out.println("exception: " + response + " " + e); |
| | | System.out.println("videoUrl exception: " + response + " " + e); |
| | | isJSON = false; |
| | | } |
| | | |
| | |
| | | Object obj = element.getAsJsonObject().getAsJsonObject("data").get("videoUrl"); |
| | | String result = obj.toString(); |
| | | if (result.length() > 0) { |
| | | videoUrl = "http://" + result; |
| | | videoUrl = result; |
| | | } |
| | | } |
| | | in.close(); |
| | | conn.disconnect(); |
| | | } |
| | | } catch (Exception e) { |
| | | System.out.println("VideoPath.getVideoUrl " + e.getMessage()); |
| | | System.out.println("videoUrl VideoPath.getVideoUrl " + e.getMessage()); |
| | | } |
| | | |
| | | System.out.println("videoUrl :" + videoUrl); |
| | | return videoUrl; |
| | | } |
| | | |