I am trying to get the last 5 songs that a Spotify user has starred. After looking at the Guess the Intro example that Spotify provides, I was able to pull the entire playlist, but I was wondering if there is a way in cocoaLibSpotify for me to only pull a certain number of songs at a time. Below is the function that I am using to get the tracks from the starred playlist:
+ (void)gatherTracksWithBlock:(void (^)(BOOL, NSArray *))block {
__block SPPlaylist *starred = [SPSession sharedSession].starredPlaylist;
[SPAsyncLoading waitUntilLoaded:starred timeout:20.0 then:^(NSArray *loadedItems, NSArray *notLoadedItems){
if ([[starred items] count] == 0) {
block(NO, nil);
starred = nil;
return;
}
NSMutableArray *topTracks = [[NSMutableArray alloc] initWithCapacity:[[starred items] count]];
for (SPPlaylistItem *item in [starred items]) {
if (item.itemClass == [SPTrack class]) {
[topTracks addObject:item.item];
}
}
block(YES, topTracks);
starred = nil;
return;
}];
}
Are there any modifications that I can make to get this function to only pull a certain number of tracks at a time? Also, if this is possible, am I able to then skip over the number of tracks that I have pulled previously?
One last question! Is it possible to gather a user's recently played tracks using cocoaLibSpotify? I was looking at older posts and the answer I saw was no, but I was wondering if anything had changed since those posts were closed.
Sorry in advance for the compound questions. It's my first time posting!
Thanks, Tyler