CocoaLibSpotify is a little weird in this way. To stop or "pause" a song you just set the playbackManager.isPlaying to no. Once you have stopped the current song it will be safe for you to call playTrack on the next track in your playlist. It could go something like:
self.nextIndex++;
if (self.playbackManager.isPlaying)
self.playbackManager.isPlaying = NO;
SPPlaylistItem *playlistItem = [self.playlist.items objectAtIndex:self.nextIndex];
if (playlistItem.itemClass == [SPTrack class])
{
self.playbackManager playTrack:(SPtrack*)playlistItem.item callback:^(NSError *error) {
if (error)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Cannot Play Track"
message:[error localizedDescription]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
}
Where next index will keep track of where you are in the playlist e.g.
@property (assign) NSInteger nextIndex;
And the playist is an instance of SPPlaylist e.g.
@property (nonatomic) SPPlaylist *playlist;
Then you can do some initializations on these in viewDidLoad. For convenience I would probably wrap that playTrack method in another method to stop the code duplication. Notice how a playlistItem.item property is essentially 100% of the time an SPTrack