music player - How to get album art from last.fm Android -
i'm making music player android, want provide feature users album art of song last.fm.
i've got api key too. need retrieving image last.fm.
any in getting image url appreciated.
thanks in advance.
p.s : more info music player, check link below https://plus.google.com/u/0/communities/115046175816530349000
i found solution check below
add below asynctask loader
public class retrievefeedtask extends asynctask<string, void, string> { protected string doinbackground(string... urls) { string albumarturl = null; try { xmlparser parser = new xmlparser(); string xml = parser.getxmlfromurl(urls[0]); // getting xml url document doc = parser.getdomelement(xml); nodelist nl = doc.getelementsbytagname("image"); (int = 0; < nl.getlength(); i++) { element e = (element) nl.item(i); log.d(log_tag,"size = " + e.getattribute("size") + " = " + parser.getelementvalue(e)); if(e.getattribute("size").contentequals("medium")){ albumarturl = parser.getelementvalue(e); } } } catch (exception e) { e.printstacktrace(); } return albumarturl; } }
call followed :
stringbuilder stringbuilder = new stringbuilder("http://ws.audioscrobbler.com/2.0/"); stringbuilder.append("?method=album.getinfo"); stringbuilder.append("&api_key="); stringbuilder.append("your_last_fm_api_key"); stringbuilder.append("&artist=" + urlencoder.encode("artist_name_here", "utf-8")); stringbuilder.append("&album=" + urlencoder.encode("album_name_here", "utf-8")); url = new retrievefeedtask().execute(stringbuilder.tostring()).get();
you need 2 classes : 1. xmlparser 2. docelement both of available in link below. xml parsing tutorial
Comments
Post a Comment