[Mono-osx] Access iTunes using C#

Bart Masschelein masschel at gmail.com
Thu Jan 17 14:29:34 EST 2008


So if I get it right, there is no way around using Applescript. This  
NSAppleScript or ScriptBridge both are concepts I've never heard of  
before, but we're never to old to learn, are we? Suppose I create an  
AppleScript to fetch all songs of a certain playlist, do the above  
allow me to get this list in objc, and eventually to C#, where I can  
for instance compare them with other playlists? Or in other words,  
could I do something like this (under the premises that this is all  
very premature):

> iTunesApplication itunes =  
> SBApplication.ApplicationWithBundleIdentifier ("com.apple.iTunes");
Song[] songs = itunes.GetPlayList("some_playlist");
foreach(Song song in songs)
{
   Console.WriteLine(song.Album);
}

, where Song would be a class representing an iTunes song. All of this  
taking into account all the layers in between (beit ScriptBridge or  
NSAppleScript). If you guys answer yes, that would make my day. That  
would mean that in order to make this generic enough, a bunch of  
relatively small AppleScript (ala FetchSongsFromPlayList, ImportSongs)  
need to be created, and wrapped into some conversion layers and  
eventually into C#.

But I hear that it will not be all that vanilla yet.

Thanks!


On 17 Jan 2008, at 20:09, Geoff Norton wrote:

> Right now there isn't much there.  However the new ScriptBridge  
> stuff combined with objc2 bindings I'm currently working on could do  
> this (assuming you actually can do the manipulation you want thru  
> applescript).
>
> Take a look at:
>
> http://developer.apple.com/releasenotes/ScriptingAutomation/RN-ScriptingBridge/index.html
>
> We could likely write a similar tool to sdp (or a post-processor; or  
> simbl; or something) to do the conversion to a C# class then you  
> could do things like
>
> iTunesApplication itunes =  
> SBApplication.ApplicationWithBundleIdentifier ("com.apple.iTunes");
>
> Console.WriteLine (itunes.CurrentTrack.Name);
>
> This is all off the top of my head tho (I havn't looked into how  
> feasible hacking sdp to that would be; you might need to manually  
> bind all that).
>
> Also my objc2 bindings are far from complete at this stage, no ETA  
> on when they'll ship yet.
>
>
> Today you could bind NSAppleScript as mentioned in the other e-mail
>
> -g
>
> On 17-Jan-08, at 1:56 PM, Bart Masschelein wrote:
>
>> Hi all,
>>
>> I was wondering if there is a way to access iTunes using Mono/C#. I
>> know there is an SDK for Windows available, but is there as well an
>> SDK for OSX? It would be rather strange if not, no? I'm not
>> particularly interested in controlling iTunes (play/stop/pause/next
>> song/etc) but rather in importing songs, changing the tags etc. The
>> ultimate idea is to synchronize between a local iTunes library and a
>> remote iTunes on another Mac. Reading the xml library file alone will
>> not do, since I would also like to actually change the library, and
>> add/remove songs. I know I could do those things using AppleScript,
>> but I am more the platform independent kind of guy, in love
>> with .NET ;-).
>>
>> cheers,
>> Bart
>> _______________________________________________
>> Mono-osx mailing list
>> Mono-osx at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-osx
>



More information about the Mono-osx mailing list