(For those of you whose eyes glaze over at the mere thought of programming, let alone discussions of it, please skip to the next entry.)
In the years since I bought my first iPod, I’ve struggled with trying to settle for the applications available for podcatching and other iTunes-related stuff. No podcatcher (even the one built into iTunes) has ever satisfied me; all of them have either lacked important features, or been too unstable, or had fatal flaws.
Throughout my computer “career,” my answer to this type of situation has always been “write it yourself.” The problem with this is that I program in Pascal, but nearly everything in the Windows world revolves around C. When iTunes released their Software Developer Kit for Windows, it was all in C. I don’t want to learn C, or C++, or C#, or any of its variants. I’m happy with what I have now.
These facts led me on a multi-year search for help in using iTunes with Pascal (or its “successor” in some people’s eyes, Delphi). The problem is that there’s been almost nothing on the web about programming iTunes in Pascal. I’d longed for people to share source code and tips, but no one has ever done so.
I refuse to be such a cheap bastard. If you’ve found this blog entry through Google, you’ve come to the right place. Until and unless I set up a full-blown iTunes/Pascal page, this is the jumping-off point you need.
1. Getting started with iTunes in Pascal
The first stop is to go over to Apple, and download their SDK. All the source code in it is for C, true, but it’s got documentation, a help file, and other information you will need as well. Plus, you really do need to accept their license agreement before you go developing stuff for iTunes. It’s the law and all that.
Next, download this Pascal unit from me. It’s a Pascal port of the type library built into iTunes.exe, the Pascal equivalent of the .h file you get in the SDK. It’s been verified to work in the three most common Pascal packages out there in the Windows world: Virtual Pascal, Free Pascal, and Delphi. I use Free Pascal myself (thus the .pp extension; change as needed).
2. Branching outward
Since my current interest is in developing a new podcatcher, I threw together a simple unit encompassing what would be the most-often needed functions of iTunes for a podcatcher: adding, converting, and removing files, and synchronizing an iPod. I’ve uploaded this unit to my server, and you may feel free to download and use it. (It would also be helpful for those of you planning more elaborate programming ventures as a teaching tool, so you can see calls to the iTunes library first hand.)
One caveat: I tend to write a LOT of helper units adding procedures, functions, and objects that make my programming life a lot easier. This simple iTunes unit uses one of those: my “FileSpecs” unit. This unit creates a Pascal/Delphi class for easy management of filenames by breaking them automatically into their component parts: path, filename, and extender. These came in very handy in writing my “Convert” routine, where I wanted to tell the program to copy a file from its current location to the location another file is in, using that file’s name instead of the one iTunes gave it, with a different extension. You’ll need my FileSpecs unit to compile my iTunesForPodcasts unit, and you are also welcome to use that unit as you see fit.
The FileSpecs.pp unit can be downloaded here.
The iTunesForPodcasts.pp unit can be downloaded here.
Let me know if they’re helpful, and also if you would like a more detailed “iTunes in Pascal” page as I progress along.


Recent Comments