0

我正在使用 cocoalibspotify。我想知道如何从 SPPlaylist 获得 SPPlaylistItem?我有自己的播放列表。如何使用播放列表(按名称)获取播放列表项?

4

1 回答 1

0

呵呵..终于我得到了答案。我找到了从播放列表中获取播放列表项的方法。

在我的研究中,我了解到播放列表项来自 keypath @unionOfArrays.items。因此,通过删除它,我只能获得播放列表列表,而不是 playlistitem 。

在此处参考我的代码:

    // arrPlaylist -> mutablearray which stores the value of loaded playlist in order to use it later 
    // tblPlaylist -> Tablename which displays list of playlist. 

[SPAsyncLoading waitUntilLoaded:[SPSession sharedSession] timeout:kSPAsyncLoadingDefaultTimeout then:^(NSArray *loadedession, NSArray *notLoadedSession) 
    {
        // The session is logged in and loaded — now wait for the userPlaylists to load.
        NSLog(@"[%@ %@]: %@", NSStringFromClass([self class]), NSStringFromSelector(_cmd), @"Session loaded.");

        [SPAsyncLoading waitUntilLoaded:[SPSession sharedSession].userPlaylists timeout:kSPAsyncLoadingDefaultTimeout then:^(NSArray *loadedContainers, NSArray *notLoadedContainers) 
        {
            // User playlists are loaded — wait for playlists to load their metadata.
            NSLog(@"[%@ %@]: %@", NSStringFromClass([self class]), NSStringFromSelector(_cmd), @"Container loaded.");

            NSMutableArray *playlists = [NSMutableArray array];
            [playlists addObject:[SPSession sharedSession].starredPlaylist];
            [playlists addObject:[SPSession sharedSession].inboxPlaylist];
            [playlists addObjectsFromArray:[SPSession sharedSession].userPlaylists.flattenedPlaylists];

            [SPAsyncLoading waitUntilLoaded:playlists timeout:kSPAsyncLoadingDefaultTimeout then:^(NSArray *loadedPlaylists, NSArray *notLoadedPlaylists) 
            {
                // All of our playlists have loaded their metadata — wait for all tracks to load their metadata.
                NSLog(@"[%@ %@]: %@ of %@ playlists loaded.", NSStringFromClass([self class]), NSStringFromSelector(_cmd), 
                      [NSNumber numberWithInteger:loadedPlaylists.count], [NSNumber numberWithInteger:loadedPlaylists.count + notLoadedPlaylists.count]);
                            NSLog(@"loadedPlaylists >> %@",loadedPlaylists);

                arrPlaylist = [[NSMutableArray alloc] initWithArray:loadedPlaylists];
                NSLog(@"arrPlaylist >> %@",arrPlaylist);

                [tblPlaylist reloadData];
            }];
        }];
    }];
于 2012-09-21T10:13:14.507 回答