【问题标题】:Differentiate iTunes internal playlists and user playlist区分 iTunes 内部播放列表和用户播放列表
【发布时间】:2021-12-20 02:47:58
【问题描述】:

关注我的previous question

当我在 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 中是否有任何属性说明哪个是默认的,哪个是我创建的?

【问题讨论】:

    标签: c# itunes-sdk


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2023-03-08
      • 1970-01-01
      • 1970-01-01
      • 2014-05-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-18
      • 2021-12-21
      相关资源
      最近更新 更多