TuneTool, a simple Apollo app

After last week’s Flex Immersion, I installed the Apollo extensions for Flex Builder, and started experimenting with that to see how it all worked. It’s actually quite seamless – very similar to building SWF based RIAs in Flex Builder, but with some extra capabilities like the File object that lets you do things with local files.

I’d written a little tool a while ago that deletes from disk files that are rated 1 star in your iTunes library, so I re-implemented that in Flex Builder. Turns out it wasn’t that tough.
If you’ve got the Apollo runtime installed, click this link:

http://www.stevex.org/flex/TuneTool/TuneTool.air

That should install the app and you can run it. It won’t do anything dangerous unless you tell it to, so it should be safe to look at.

It uses view states to transition through the 4 phases of the UI, and binding for various things, all of which make the application very easy to write and understand, assuming you know a bit of Flex.

Flex Builder also generates a source browser, which you can see here:

http://www.stevex.org/flex/TuneTool/srcview/index.html

The model.TuneModel class does some very simple parsing of the iTunes Music Library.xml file to find the deleted tracks and returns an array of them, leveraging E4X to turn the bizarre iTunes format into a dictionary of name/value pairs that’s easy to work with in the rest of the app.

One odd thing I had to do is turn the iTunes file://localhost/path format into the file:///path format that Apollo’s File object’s url field expects.

I particularly liked the way I could bind the columns of the DataGrid to the radio button state, to switch between two different views of the data with no code.

Here’s how I use this tool:

As I’m out with my iPod or listening with iTunes, if I hear a song I know I don’t like and likely never will like, I mark it with 1 star.

Later, I run this tool to delete all those 1 star files, and then in iTunes, filter for all the files with 1 star and remove them from the library.  iTunes will remove them from the library, but won’t actually get rid of the files (unless you let it manage your music library, which I don’t).

So not only is this my first Apollo app, but it’s something that I find actually quite useful. Let me know if it works (or doesn’t work) for you.