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. kalen says:

    that’s sweet man. would be cool to aggregate “currently listening” data from thousands of people simultaneously and pop it into a sidebar on amazon.com.

  2. Dougal says:

    For aggregated music listening info, see also: audioscrobbler.

  3. Mike says:

    I use a combination of audioscrobbler a hosted script and a teeny tiny bit of html…

    The nicest thing about audioscrobbler is the great ranking system they have for your tunes… after a few months you can get fairly accurate recommendations of new music you may like to check out.

  4. Anthony says:

    That is exactly what I’ve been looking for. I hope you can make it available someday.

  5. Dougal says:

    I was going to use my audioscrobbler feed originally, but I’ve been getting inconsistent results from their XML feed. For instance, sometimes it doesn’t include the album name (even though it exists in the track ID3 info on my end). That puts a serious kink in the usage. I haven’t figure out yet why it does that sometimes, and sometimes not. Plus, the servers tend to get bogged down, and the information is rarely close to real-time.

  6. Aaron says:

    P.O.D.

    Niiiiice… ;)

  7. Ingrid says:

    Did you know that there is a iTunsspy plugin that works with WordPress ?
    http://www.crea-doo.at/itunesspy/

  8. Dan Atkinson says:

    Don’t be embaressed to let people see your code. It’s people like you who open blogging up to the mainstream public that it’s become. Anything that improves the way that we can inform others of what we’re doing and what we’re up to is a bonus on any blog!

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

  10. So, Dougal, what is your Audioscrobbler username? :)

  11. Dougal says:

    I’m thinking that you could probably guess my username :)

  12. Pingback: geek ramblings » Microformat for media descriptions

  13. Pingback: geek ramblings » Upgraded

Leave a Reply

%d bloggers like this: