Dougal Campbell's geek ramblings

WordPress, web development, and world domination.

Now playing…

About a year ago, I started to work on some code to include a “now playing” feature here. It would track music I was listening to in my media player (Winamp, at the time), and put the info in the sidebar of this site. I looked at various canned code solutions, but I usually like doing these things myself. But it wasn’t a high priority, so I just tinkered with it here and there, and never really finished it up.

Since then, I’ve changed jobs, moved into a new house, switched from Winamp to iTunes, and I generally have had less free time available. So the unfinished PHP code sat on my server’s drive collecting dust for quite a while. Recently, while poking through my files looking for something else, I spotted the old files, and it revived my interest. So, over the last week or so, I tinkered with it some more during short breaks, and finally got it working well enough to throw something up.

You can see the results near the top of the sidebar, under the new “Media” heading (I plan to add books and movies, eventually). It will only show songs for which it can locate an Amazon.com product, so it won’t reflect my full musical selection (though the other songs are still tracked in the database, and I might expose those at some point). If the selection is preceded by “Currently”, then I was listening to that selection at the time you loaded the page. If it says “Recently”, then it’s showing the last song I listened to, and I’ve either shut down iTunes, or it couldn’t locate my current song on Amazon.

The hardest part about getting it working was locating a decent free plugin for iTunes to transmit the song info to my server. I finally settled on AMIP. AMIP is geared more for hooking into an IRC or IM client, but it’s capable of calling out to external programs, and the docs show examples of using cURL to transmit information to a web server. For the Amazon integration, I used the AmazOOP PHP library.

Maybe one day, I’ll clean up the code and make it available. But right now, it’s very messy, full of unused variables and hardcoded HTML markup, and the database isn’t normalized, so I’d be embarassed for anybody else to look at it. I also want to capture some more data in the database (mainly my iTunes rating for each song) before I’m done.

In the interest of full-discosure, if you click on the links to Amazon, and purchase something, I’ll get a small kickback. Obviously, I encourage you to do so 🙂

About Dougal Campbell

Dougal is a web developer, and a "Developer Emeritus" for the WordPress platform. When he's not coding PHP, Perl, CSS, JavaScript, or whatnot, he spends time with his wife, three children, a dog, and a cat in their Atlanta area home.
This entry was posted in Music, Tech and tagged , , , , , , , , , . Bookmark the permalink.

14 Responses to Now playing…

  1. Pingback: Sean Buckley Blog » Blog Archive » Wordpress Plugin: WP-Scrobbler

  2. Pingback: geek ramblings » Microformat for media descriptions

  3. Pingback: geek ramblings » Upgraded

Leave a Reply to Mike Cancel reply

%d bloggers like this: