0

按照我之前的问题

当我在 iTunes 库中获取播放列表时,我得到一些似乎是 iTunes 的默认播放列表的条目

这是我的代码:

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
        }
    }
}

这是结果:

在此处输入图像描述

您会看到我创建了一个名为“音乐”的播放列表。还有一个名为“音乐”的默认条目。如何区分这两个播放列表?iTunesLib 中是否有任何属性表明哪个是默认的,哪个是我创建的?

4

1 回答 1

0

使用KindSpecialKind属性,我能够实现一个解决方案:

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
        }
    }
}
于 2021-12-26T08:26:32.400 回答