Reputation: 195
I implemented Spotify
in my application using CocoaLibSpotify
library. I am playing spotify songs from different pages of my app. The problem is, after I played a song then when I try to play another song from another page, it plays the old song for some moments.
This is some code sample.
self.playbackManager = [[SPPlaybackManager alloc] initWithPlaybackSession:[SPSession sharedSession]];
self.playbackManager.playbackSession.playbackDelegate = (id)self;
[self.playbackManager playTrack:track callback:^(NSError *error)
{
if ((error || ([track availability] != SP_TRACK_AVAILABILITY_AVAILABLE)))
{
}
else
{
}
}];
Please help me to fix the issue.
Upvotes: 1
Views: 101
Reputation: 18776
It sounds like you're creating a new playback manager for each page of your app. Don't do this, or they'll overlap one another.
Have only a single playback manager in your whole app - that way, when you play a new track using playTrack:callback:
, the new track will replace the old one instantly. Note that you do not set the currentTrack
property directly - it's read-only.
Upvotes: 2