CocoaLibSpotify resets offline available tracks to SP_TRACK_OFFLINE_WAITING during log in

主宰稳场 提交于 2019-12-25 08:49:21

问题


I'm having a problem with CocoaLibSpotify when trying to save my playlists for offline use.

So I install my app, log in for the first time, select a playlist and set it for offline use, immediately its offlineStatus changes to SP_PLAYLIST_OFFLINE_STATUS_DOWNLOADING, all the tracks in the playlist have their offlineStatus changed to SP_TRACK_OFFLINE_WAITING, they start downloading one at a time and eventually their offlineStatus changes to SP_TRACK_OFFLINE_DONE. I turn off my wifi and I can play the downloaded tracks offline.

When I close the app and log in again, the tracks that were previously available offline now have their offlineStatus changed to SP_TRACK_OFFLINE_WAITING and can no longer be played offline. CocoaLibSpotify stores the downloaded playlists in the NSCachesDirectory, if I check that folder I see that the content hasn't changed and the track data is still there.

Another strange thing, I assume that, even in online mode, CocoaLibSpotify will play the downloaded track from the device if it's available offline. If I turn on wifi and I start playing on of these previously downloaded SP_TRACK_OFFLINE_WAITING tracks, then quickly turn off wifi, it still continues to play the entire track.

So from the looks of it, I'm assuming the tracks still remain offline but for some reason their offlineStatus gets the wrong status when logging in. And that the session refuses to start playing the track because of its offlineStatus.

But how can I avoid the tracks having their offlineStatus reset or at the very least, correct the problem when I know the track has been downloaded. I've tried setting the offlineStatus to SP_TRACK_OFFLINE_DONE manually but that didn't work. I'm hoping someone can shed some light on this.

Thanks in advance.


回答1:


Manually setting the property won't affect anything but your UI.

There's a couple of things to check:

  • When you quit your application, make sure you logout ([SPSession -logOut]) and wait until the logout completes before letting the application die, otherwise you might get a broken cache.

  • When you log back in again, are you using CocoaLibSpotify's saved credentials or manually entering your password again? If it's the latter, it won't work since the library can't contact the Spotify service to verify the credentials. Using CocoaLibSpotify's built-in credential saving doesn't have this problem.



来源:https://stackoverflow.com/questions/10356916/cocoalibspotify-resets-offline-available-tracks-to-sp-track-offline-waiting-duri

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!