1

Following my previous question

When I fetch Playlists in iTunes library I get some entries which seems to be default playlists for iTunes

Here is my code:

App = new iTunesAppClass();
IITSourceCollection sources = App.Sources;

foreach (IITSource src in sources)
{
    if (src.Name == "Library")
    {
        IITPlaylistCollection pls = src.Playlists;
        foreach (IITPlaylist pl in pls)
        {
            // add pl.Name to a List<string> and them show them on TreeView
        }
    }
}

This is the result:

enter image description here

You see that I have created a playlist named "Music". There is also a default entry named "Music". How can I differentiate these two playlist ? Is there any property in iTunesLib which says which one is the default one and which is the one I have created?

FLICKER
  • 6,439
  • 4
  • 45
  • 75

1 Answers1

0

Using Kind and SpecialKind properties, I was able to implement a solution:

App = new iTunesAppClass();
IITSourceCollection sources = App.Sources;

foreach (IITSource src in sources)
{
    if (src.Name == "Library")
    {
        IITPlaylistCollection pls = src.Playlists;
        foreach (IITPlaylist pl in pls)
        {
            /* here is the trick */
            if (p is IITUserPlaylist)
            {
                var upl = (IITUserPlaylist)p;
                if (upl.SpecialKind != ITUserPlaylistSpecialKind.ITUserPlaylistSpecialKindNone)
                    continue;
            }

            /* and this one */
            if (p.Kind == ITPlaylistKind.ITPlaylistKindLibrary)
                continue;

            // add pl.Name to a List<string> and them show them on TreeView
        }
    }
}
FLICKER
  • 6,439
  • 4
  • 45
  • 75