Feature Request: iTunes database access

It’d be nice to be able to access a local iTunes music database with a JUCE styled interface and native implementations for each platform,

I actually did this a while ago, its in the dRowAudio module under the ‘utility’ directory and there is a page in the demo app to demonstrate it.

It comes in three parts, the library parser (ITunesLibraryParser) which converts the iTunes xml database to a ValueTree, the ITunesLibrary which manages the parser and has a listener interface to update for example the MusicLibraryTable which displays the library in a table and deals with all the drag and drop stuff etc.

To use it, is pretty simple:

ITunesLibrary::getInstance()->setLibraryFile (ITunesLibrary::getDefaultITunesLibraryFile()); MusicLibraryTable* musicLibraryTable = new MusicLibraryTable; musicLibraryTable->setLibraryToUse (ITunesLibrary::getInstance());

The parser runs on a background thread and all callbacks are made on the message thread. The idea was that you could generate the ValueTree formatted library, make changes to it such as add properties and children of tracks for cue, loop points etc and save it. You could then load this modified library back in and the parser would update it if the iTunes library has been modified without destroying your modifications.

Can’t remember how far I got with that last part and the parsing could probably be speeded up in places but it does work. I will clean it up a bit more soon but I’m a bit snowed under with other projects at the moment.

Let me know what you think and if you have any ideas for it that would be great.

(What I think I do need to do is filter the tracks based on what the system can play, pretty much all formats work on my Mac but I don’t think the WindowMediaAudioFormat can play m4a files)

Wow!!! I was looking for something much simpler…something that uses the iTunes COM SDK but this could be a convenient alternative!

Didn’t know that existed, although I didn’t really research it too much, think I took the Jules approach on this one and just did it myself. It should be cross-platform and stable providing they don’t change the iTunes spec any time soon.

Perhaps a native implementation would be good although I haven’t got time to look into it at the moment. The ValueTree my parser spits out is pretty concise and flexible though.

I believe that when you use the COM interface (on Windows at least), the results are “live” - it communicates directly with iTunes and therefore, can make changes to the iTunes dataset while it is running.

Yeh thats one thing mines doesn’t do, it creates a copy of the library, theres no way to edit the original. To be honest I was a bit scared of having that power and possibly being able to trash a user’s library.

The inspiration behind my design was Scratch Live which I ‘think’ parses the iTunes Library and when you edit tags actually changes the ID3 tags of the files which then gets picked up later by iTunes.

A similar technique could be employed here using TagLib or something similar. Didn’t you do some TagLib wrappers in one of your modules?

I’m about 80% positive that Scratch Live uses the iTunes COM SDK, since iTunes updates if it is running.

I’ve amalgmated TagLib, and also I have included that amalgamation in VFLib. Both are in my signature. I have not yet put any wrappers around TagLib.

You’re probably right, I was thinking more on the Mac side though, I only ever use Windows for compiling and testing projects. I thought iTunes might use the fsevent framework to pick up changes to the audio files and rescan the ID3 tags which I know Scratch Live updates.

It would probably be quicker and safer to use the COM framework although it looks like iTunes is accessed through applescript on the Mac unless they have added some new apis in AVFoundation. I know you can use the MediaPlayer framework on iOS for iPod library access but there doesn’t seem to be a Mac equivalent.

Will definitely have to investigate further at some point.