Tuesday, August 07, 2007

Fun with Pandora

Thanks to some help from the Pandora guys, I was able to create this nifty little mashup. Using a javascript event API from Pandora, I register a javascript callback that is invoked when a new song plays in the embedded Pandora player. I get the artist name and track title from an object passed to the event handler, then construct a URL that passes these as search terms to the SNOCAP Search API. I use a simple roll-your-own AJAX call with the XMLHttp/XMLHttpRequest object to fire off the search, then parse the JSON results in the response callback. Using the results, I populate a table with the matching artist names and track titles, then render the first item on the list as a flash SNOCAP MyStore. The only back-end work being done here is the call to the search engine, and that is all done asynchronously so the user doesn't get interrupted as the Pandora radio is playing.

To prevent the active store from being blown away when a new song starts, I give the user the ability to "freeze" the store, or open it in a new browser window.

Post a Comment