带
源码的
音乐搜索APIjar包,一导入。
将这些jar包导入工程即可,使用方法如下
package music_basic;
i
mport java.util.List;
i
mport org.apache.commons.lang.StringUtils;
i
mport music.MusicBasic;
i
mport bean.MusicBody;
i
mport bean.MusicData;
i
mport bean.MusicUrl;
public class MusicTest {
public static void main(String[] args) throws Exception {
MusicBody musicBody = MusicBasic.getMusic("稻香");
String albumId = "";
if (musicBody.getStatus() == 1) {
List<MusicData> datas = musicBody.getDat
as();
for (int i = 0; i < datas.size(); i++) {
System.out.println(datas.get(i).getSo
ngName());
MusicUrl musicUrl = MusicBasic.getMusicUrl(datas.get(i));
System.out.println(musicUrl.getFileUrl());
System.out.println(musicUrl.getPicUrl());
System.out.println(musicUrl.getLyrics());
System.out.println(musicUrl.getAlbumI
d());
albumId = musicUrl.getAlbumI
d();
if (StringUtils.isNotEmpty(albumId)) {
break;
}
}
}
if (StringUtils.isNotEmpty(albumId)) {
List<MusicData> datas2 = MusicBasic.getMusicDataByAlbumI
d(albumId);
for (int j = 0; j < datas2.size(); j++) {
MusicUrl musicUrl2 = MusicBasic.getMusicUrl(datas2.get(j));
System.out.println(musicUrl2.getSo
ngName());
}
}
}