The portfolio, resume, and blog of Nathan Chase
28 Jul 2008

Now that music has become mostly a commodity in the minds of consumers, music industry companies are having to think of new solutions in order to stay relevant and profitable. While they struggle to figure out how to reach those consumers, companies like Last.fm, Pandora, and Slacker are exploring today’s real innovation in music – customized and personalized listening experiences.
While all three services offer their own unique implementations of online radio, there are a number of ways that each solution trumps the rest in features and user experience. Let’s dive in to a comparison and find out what makes these services so slick:
28 Aug 2005
Well I dove headfirst into some Flash programming this weekend and came out with a success. Now I know this is probably not the most efficient way, correct way, or best way to do this, but it got my XML parsing chops up, and I learned how to tap into the Amazon API while creating it. I’m stoked at the result.
What it’s doing is it’s taking my last played song’s Album Title and Artist Name (thanks to Audioscrobbler/last.fm) and sending it along to Amazon as a keyword search. Amazon then gives back an XML file with the results, and then my Flash app parses the XML and finds the node with the CD cover that matches the keyword’s search results. So if you look over there in the sidebar, you’ll see that the cover appears as it would show on Amazon. Pretty neat huh?
And here’s the code, if any Flash junkies want to see what I was working on. If you have any questions about it, email me or hit me up on IM. I still have to add something if there is no image available, and maybe try another service (Google, AllMusic) if Amazon comes up short.
// Allow this Flash app to show the loaded images consistently from the remote server, images.amazon.comSystem.security.allowDomain("http://images.amazon.com");////var audioscrobblerURL = "http://ws.audioscrobbler.com/rdf/history/[YOURPROFILENAMEHERE]";var audioscrobblerReply_xml:XML = new XML();audioscrobblerReply_xml.ignoreWhite = true;audioscrobblerReply_xml.onLoad = function(success) { if (success) { // trace(audioscrobblerReply_xml); processAudioScrobblerXML(audioscrobblerReply_xml); } else { trace("error loading"); }};audioscrobblerReply_xml.load(audioscrobblerURL);function processAudioScrobblerXML(audioscrobbler_xml) { audioscrobblerArtistTitle = audioscrobbler_xml.firstChild.firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.firstChild.firstChild; trace(audioscrobblerArtistTitle); audioscrobblerAlbumTitle = audioscrobbler_xml.firstChild.firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.firstChild.firstChild; trace(audioscrobblerAlbumTitle); // set the standard Amazon URL var amazonURL = "http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&SubscriptionId=[YOURDEVIDHERE]&Operation=ItemSearch&Keywords="; var urlEnd = "&SearchIndex=Music&ResponseGroup=Images"; var keyword = audioscrobblerAlbumTitle+" "+audioscrobblerArtistTitle; // create new XML var amazonReply_xml:XML = new XML(); // ignore the whitespace amazonReply_xml.ignoreWhite = true; // trace the returned XML and process it amazonReply_xml.onLoad = function(success) { // trace(amazonReply_xml); if (success) { processXML(amazonReply_xml); } error = "error loading"; }; // send off the URL to pull back the new XML data from Amazon (note variable "keyword" comes from textfield on stage) amazonReply_xml.load(amazonURL+keyword+urlEnd); // create the function of processing the returned XML function processXML(amazon_xml) { // amazon_xml is now a reference to the XML // object where information is stored // trace(amazon_xml.firstChild.firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.firstChild.firstChild); albumCoverURL = amazon_xml.firstChild.firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.firstChild.nextSibling.nextSibling.firstChild.firstChild; //load CD Cover image into movieclip on stage imageHolder.loadMovie(albumCoverURL); }}