Dealing with iTunes freezing up in Windows

Righty, fair enough, this post isn’t really along the lines of most of my other ones, but it has to be said that I’ve been particularly faithful to iTunes in the past, and I’m fairly certain I’ve blogged about things that have bugged me which I’ve fixed / resolved in one way or another. Tonight I decided to finally sort out another annoying ‘feature’ of iTunes, whereby it would freeze up every time a new song started playing.

As a quick background on my situation, I’m on a 64-bit Windows 7 install, but I’m fairly certain I’ve been suffering this throughout my time on a 32-bit Vista install as well. Whilst I obviously can’t be completely certain, the following has resolved the issue for me, and at least to me, it makes sense.

I’ve used Google Desktop for some time to index my system to make it searchable. I long resisted using one of these ‘always indexing’ applications, but I gave in a few years back when I got a decent computer, powerful enough that any slowdowns caused by constant indexing are negligible. My opinion now is that it’s a real life saver – and you should certainly consider installing it.

There is a caveat with these indexing tools however, and it’s pretty obvious: it likes touching all your files. Especially the ones you’re currently working with. This leads to frustration when I compile code, test something, and then want to send it off to the Windows equivalent of /dev/null – the files are being indexed by Google Desktop, and Windows packs a sad. When I’m doing a lot of compile/test/delete cycles, I normally turn off Google Desktop for a few hours – it makes life easier.

So, getting onto the iTunes freezeup issue. For whatever reason – I never looked into it – iTunes writes out to an XML file every time a new song plays. I’m sure you can see where this is going: it seems like there is a little bit of a tussle going on between iTunes and Google Desktop, leading to this iTunes freezeup.

Fortunately, the solution is simple: in Google Desktop (or your indexing system of choice), simply go into the preferences, and tell it to not bother indexing the following file:

c:\users\<account name>\appdata\roaming\apple computer\itunes\iTunesPrefs.xml

Of course, replace <account name> with your windows user name.

After doing this, everything works far better for me in iTunes. I probably won’t have another complaint for six months 🙂

I hope this helps.

Control iTunes using keyboard media keys

Just a quick post: I have had a really bad programming itch ever since I got my new Dell laptop recently. It has a row of media keys to go back, forward, play/pause and stop my music. Unfortunately, these keys only work when iTunes has the focus, which kind of sucks. I decided, finally, to do something about it, and wrote a small program that lets you control iTunes using these media keys, even when it doesn’t have focus. The program lives in your system tray, and you can exit it by right-clicking on it.

There are a number of issues with it, and things I could improve, including:

  • It only works on Windows.
  • It requires Java 6.
  • It only works on x86 computers, although if anyone wants, I can make it work on x64 with a little testing.
  • It allows for multiple instances to be run, meaning that if you have two instances running, clicking back on your keyboard will take you back two songs.
  • It doesn’t give any song notification, etc – it is just a controller. If people really want song notification, let me know.

As you should note, the amount of code written is actually minimal: this project is mostly just tying together two other libraries, and of course the iTunes COM interface.

There is a zip file here that contains everything – libs, source code, and a batch file that you can use to start the program. Normal lazy programmers license applies: if your computer crashes and burns, send me photos, but please no complaints. If you use it and (dis)like it, let me know!

Jonathan Giles