1

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; {

}
Nik Reiman
  • 39,067
  • 29
  • 104
  • 160
joshb
  • 63
  • 4
  • I have the same problem, weird that you asked this today. Is something wrong with the service or are we doing something incorrectly? – davis Jan 02 '13 at 20:14
  • So, the method should look like this `-(void)sessionDidEndPlayback:(id )aSession {}`, but it's still not working for me. – davis Jan 02 '13 at 20:24
  • I think we are doing something incorrectly, it hasn't ever worked for me. I may be implementing the SPSession delegate incorrectly, because some of the other callbacks from that delegate are also not working. I've tried a few things and still haven't gotten to the bottom of it. – joshb Jan 03 '13 at 07:34

1 Answers1

3

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.

iKenndac
  • 18,730
  • 3
  • 35
  • 51
  • Could you tell me where Can I find the playbackManagerIsFinishingPlayback method. I have searched a lot but couldn't find it – Tendulkar Mar 27 '14 at 09:39
  • 1
    As the answer says, it's on the dev branch of the project on gitHub. It's not in a stable release yet. – iKenndac Mar 27 '14 at 11:33