1

I'm having problems with receiving changes on a playlist (added, removed, and moved tracks).

I have the following flow:

  • create SPSession
  • login
  • create Playlist from URI

Then I change the playlist in the Spotify desktop app by adding, removing and moving some tracks. Exactly 2 changes are notified via callbacks on my SPPlaylistDelegate. But then it stops. No changes in the playlist are notified anymore. This was working perfeclty on an older version of CocoaLibSpotify.

Can anyone help me with this one?

Pfitz
  • 7,336
  • 4
  • 38
  • 51
Emiel
  • 144
  • 4

1 Answers1

0

Without code I can't really answer concretely, but a few things to watch out for:

First, simple stuff:

1) Does this happen in the sample apps? 2) Are you keeping a strong reference to the playlist so it doesn't get deallocated?

More advanced:

3) Are you sure the events aren't being coalesced into one change that encapsulates more than one action? 4) Are you checking the items property of the playlist — are they in sync? 5) How long are you waiting for the changes? They can take a little while to come through — just because one event was immediate doesn't mean the next one will be.

But I really need to see some code to answer this properly.

iKenndac
  • 18,730
  • 3
  • 35
  • 51
  • Thanx for the feedback. 1) Does this happen in the sample apps? Yes. I changed Guess The Intro to receive callbacks whenever one of the user playlists is changed. Therefor I added this code snippet in waitAndFillTrackPool just after the playlists are loaded: for(SPPlaylist * pl in loadedPlaylists) { NSLog(@"setting delegate on playlist '%@'", pl.name); pl.delegate = self; } – Emiel Jun 19 '12 at 19:33
  • And I implemented the following callbacks: - didRemoveItems - didAddItems - didMoveItems Max 2 callbacks are called, even after more than an hour of waiting.. – Emiel Jun 19 '12 at 20:02
  • 2) Are you keeping a strong reference to the playlist so it doesn't get deallocated? YES 3) Are you sure the events aren't being coalesced into one change that encapsulates more than one action? I'm sure 4) Are you checking the items property of the playlist — are they in sync? How should I check the items? 5) How long are you waiting for the changes? For several hours.. I hope this might lead to a solution. – Emiel Jun 19 '12 at 20:06
  • I was just playing with my version of Guess The Intro. I have 3 playlists. When changing playlist 1, max 2 callbacks on the playlist delegate are called. But guess what, after changes on playlist 1 are no longer notified, changes on playlist 2 and 3 have the same result: so max 2 changes on every playlist available are notified on the delegate. – Emiel Jun 19 '12 at 20:30
  • 4) Are you checking the items property of the playlist — are they in sync? How should I check the items? — KVO on the items property. – iKenndac Jun 19 '12 at 22:19
  • Check, this was the missing link! Thanx. So the items prop has to be observed in order to receive callbacks on the delegate. Is this requirement described somewhere in the docs? – Emiel Jun 20 '12 at 08:33
  • Wait, so adding the KVO means you start getting the delegate methods again properly? That sounds broken. Can you verify that it wasn't some coincidence? – iKenndac Jun 20 '12 at 09:27
  • It was no coincidence. I tested it several times with Guess The Intro having the same result. – Emiel Jun 24 '12 at 16:42