Juice
Juice
The Better RSS Reader
Subscribe
RSS
(What is this?)
Latest Comments
Email me Send me Feedback
Technorati Profile
Copyright 2003-5 Randy Charles Morin
Sat, 07 May 2005 14:20:47 GMT
iPod in C#

I was trying to figure out how to program my new iPod via C#. My first thought was to Google up some sample code, but to my surprise, I found nothing. So, trial and error and here's a starting point for anybody else interested in this endeavor.

public iTunesLib.iTunesAppClass app;
public iTunesLib.IITIPodSource ipod;

public iTunesLib.IITIPodSource IPodSource()
{
  
foreach(iTunesLib.IITSource source in this.app.Sources)
   {
      if (source.Kind == iTunesLib.ITSourceKind.ITSourceKindIPod)
      {
         
return (iTunesLib.IITIPodSource)source;
      }
   }
  
return null;
}

public iTunesLib.IITPlaylist Playlist(string name)
{
  
foreach(iTunesLib.IITPlaylist pl in this.ipod.Playlists)
   {
     
if (pl.Name == name)
      {
        
return pl;
      }
   }
  
object obj = this.ipod;
   return this.app.CreatePlaylistInSource("kbJuice", ref obj);
}

public static void Main(string[] args)
{
  
MainClass o = new MainClass();
  
o.app = new iTunesLib.iTunesAppClass();
  
o.ipod = o.IPodSource();
  
iTunesLib.IITUserPlaylist upl = (iTunesLib.IITUserPlaylist)o.Playlist("kbJuice");
  
iTunesLib.IITOperationStatus status = upl.AddFile(@"filename");
  
while (status.InProgress)
  
{
     
System.Threading.Thread.Sleep(1000);
  
}
  
o.ipod.UpdateIPod();
  
o.ipod.EjectIPod();
}

Permalink
Comments
+del.icio.us
Tell-a-Friend
Categories: 
Comments Closed!