zhangzengfei
2020-06-18 aeca1003b8abc4b7e5dfe56228827bbcaae937be
app/src/main/java/com/basic/security/utils/VideoPath.java
@@ -1,5 +1,6 @@
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;
@@ -19,12 +20,13 @@
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);
@@ -39,14 +41,14 @@
                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;
                }
@@ -54,17 +56,15 @@
                    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;
    }