Reputation: 63
I've included the SPSessionPlaybackDelegate and have included the method:
-(void)sessionDidEndPlayback:(SPSession *)aSession {
NSLog(@"song ended");
}
Yet this is not called when the song ends its playback naturally. Is there something I should be doing extra to implement this delegate? Other such methods are being called at the appropriate time:
-(void)sessionDidLoginSuccessfully:(SPSession *)aSession; {
}
Upvotes: 1
Views: 237
Reputation: 18776
sessionDidEndPlayback:
is part of the SPSessionPlaybackDelegate
protocol, not SPSessionDelegate
. It's called on whichever object is set as the playbackDelegate
of the session object.
However, if you're using SPPlaybackManager
for audio playback, that class sets itself as the session's playbackDelegate
when you create it, and requires that it stays that way.
Currently, SPPlaybackManager
doesn't provide a delegate method for the track ending, so the way to do this in the current release of CocoaLibSpotify is to observe SPPlaybackManager
's currentTrack
property — when it goes nil
, you know playback has ended.
The dev
branch of CocoaLibSpotify has just added the method playbackManagerIsFinishingPlayback:
to SPPlaybackManager
's delegate protocol.
Upvotes: 3