use of com.wm.remusic.json.MusicFileDownInfo in project remusic by aa112901.
the class MusicFileDownInfoGet method run.
@Override
public void run() {
try {
JsonArray jsonArray = HttpUtil.getResposeJsonObject(BMA.Song.songInfo(id)).get("songurl").getAsJsonObject().get("url").getAsJsonArray();
int len = jsonArray.size();
MusicFileDownInfo musicFileDownInfo = null;
for (int i = len - 1; i > -1; i--) {
int bit = Integer.parseInt(jsonArray.get(i).getAsJsonObject().get("file_bitrate").toString());
if (bit == downloadBit) {
musicFileDownInfo = MainApplication.gsonInstance().fromJson(jsonArray.get(i), MusicFileDownInfo.class);
} else if (bit < downloadBit && bit >= 64) {
musicFileDownInfo = MainApplication.gsonInstance().fromJson(jsonArray.get(i), MusicFileDownInfo.class);
}
}
synchronized (this) {
if (musicFileDownInfo != null) {
arrayList.put(p, musicFileDownInfo);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.wm.remusic.json.MusicFileDownInfo in project remusic by aa112901.
the class Down method getUrl.
public static MusicFileDownInfo getUrl(final Context context, final String id) {
MusicFileDownInfo musicFileDownInfo = null;
try {
JsonArray jsonArray = HttpUtil.getResposeJsonObject(BMA.Song.songInfo(id).trim(), context, false).get("songurl").getAsJsonObject().get("url").getAsJsonArray();
int len = jsonArray.size();
int downloadBit = 192;
for (int i = len - 1; i > -1; i--) {
int bit = Integer.parseInt(jsonArray.get(i).getAsJsonObject().get("file_bitrate").toString());
if (bit == downloadBit) {
musicFileDownInfo = MainApplication.gsonInstance().fromJson(jsonArray.get(i), MusicFileDownInfo.class);
} else if (bit < downloadBit && bit >= 64) {
musicFileDownInfo = MainApplication.gsonInstance().fromJson(jsonArray.get(i), MusicFileDownInfo.class);
}
}
} catch (NumberFormatException e) {
e.printStackTrace();
} catch (JsonSyntaxException e) {
e.printStackTrace();
} catch (NullPointerException e) {
e.printStackTrace();
}
return musicFileDownInfo;
}
Aggregations