spotify / ios-sdk

Spotify SDK for iOS
https://developer.spotify.com/documentation/ios/
658 stars 186 forks source link

playerStateDidChange and pause callback fire before player is paused #117

Open WickedChicken42 opened 5 years ago

WickedChicken42 commented 5 years ago

The callback on the PlayerAPI.pause() method and the SPTAppRemotePlayerStateDelegate:playerStateDidChange notification are occurring before the player has actually stopped playing. Other than introducing a 0.2 second delay before reacting is there a better work around for this, or hopefully it will get fixed. Using iOS SDK 1.0.2 iOS v12.2, iPhone XS Max, Spotify v8.5.1.1085

kkarayannis commented 5 years ago

Hi! Thanks for raising this as an issue. The delay is because the music fades out instead of stopping immediately when the pause command is issued. We consider it the right approach to update the UI immediately rather wait the fade-out to finish, and that's how the main Spotify app works as well. Does your app have a specific need to wait? If so let us know and we will consider it for future updates.

WickedChicken42 commented 5 years ago

Yes mine does. My app allows the user to configure fade outs on a per-track basis and in resetting the volume my intent was to reset the volume upon the track being finished. I had to introduce a 0.2 delay so that I don't bump the volume back up only to get a blurb of unexpected ending sounds as the track actually finishes out. There is value in knowing when Spotify's fade out has begun but I would also like to see it notify 3rd party apps when the player is truly done-done with a track. Perhaps make it a session manager configuration option so that I can choose to be notified/calledback at the start of fade out (default) or when the player is truly finished (dev choice) or make two pause methods whose callbacks will return at different stages.

Thanks for considering this idea.