iTunes COM API C#: Playlists

After a comment on my original iTunes COM API post inquiring about Playlists, I decided to revisit that part of the project. I had originally intended to include this in the first post, but it was more difficult than I had first though. Here are some code snippets to get you started:

  1. Create a ComboBox listing the names of all the playlists:

    foreach (IITPlaylist pl in app.LibrarySource.Playlists)
    {
        comboBox1.Items.Add(pl.Name);
    }
    
    Notes:
    • Retrieves all playlists in iTunes

  2. Playing One:

    private void button1_Click(object sender, EventArgs e)
    {
        IITPlaylist pl = app.LibrarySource.Playlists[comboBox1.SelectedIndex + 1];
        pl.PlayFirstTrack();
    }
    
    Notes:
    • Could also be done on ComboBox1.SelectedIndexChanged()

    • +1 Accounts for differences in indexes

This is just some basic examples, for tons more information, check out this link. You have to login in with your iTunes account, but look for "iTunes COM for Windows SDK (ZIP)" If you have trouble locating this file, email me and I can get it to you. It includes iTunesCOM.chm, which is the de-facto resource for all of this information. Between my example code (Here and here), you should be able to preform many of the iTunes functions. As always, comment if you have any troubles.


blog comments powered by Disqus