ios-sdk icon indicating copy to clipboard operation
ios-sdk copied to clipboard

How can playerStateDidChange tell that a song is changing?

Open rolflocher opened this issue 6 years ago • 5 comments

Right now, I am using the incoming playerstate uri to check if a new song has started playing. But if a user has the same song played twice, there is no way to tell that the queue has been popped from.

The only alternative I can think of is checking if the playback position of the incoming playerState is less than a second. But that could cause unexpected behavior.

When a song changes, a SPTAppRemoteSubscriptionEvent is logged in the console. Is there a way to parse what event its reporting?

This could be especially useful, considering events such as an enqueue trigger a change of playerstate as well. But all the developer is notified of is an updated playback position.

rolflocher avatar Feb 07 '20 17:02 rolflocher

I'm having this same issue as well. Being able to tell when a song is changing is basically a necessity to creating an app that plays more than one song via the app remote. @rolflocher if you found any workaround in the past couple of months, would you mind pointing to an example?

ChopinDavid avatar Mar 24 '20 22:03 ChopinDavid

@ChopinDavid I haven't found a workaround other than considering checking the playback position and crossing my fingers." Instead of doing that, we try to forbid having the same song twice in a row.

rolflocher avatar Apr 12 '20 00:04 rolflocher

@rolflocher I just ended up giving up on the project just due to the difficulty. But yes, preventing the same song being queued twice was my initial only work around I could think of.

ChopinDavid avatar Apr 12 '20 02:04 ChopinDavid

@kkarayannis playerStateDidChange is called 3-4 times when a song changes, within one second. Often the third call has a lesser playback position. Even for apps only using the Spotify SDK to reflect player state in UI, this is not expected behavior.

rolflocher avatar Apr 27 '20 17:04 rolflocher

#248

rolflocher avatar May 07 '20 15:05 rolflocher