spotify / ios-sdk

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

Local device always plays music, frequent disconnects and constant Issues reconnecting to the API. #371

Closed DandrewsDev closed 1 year ago

DandrewsDev commented 1 year ago

I have been running into a couple of issues when working with the Spotify iOS SDK.

First: Every time I do a request to get an authorization code, my device takes over playing music. This is really not ideal for me, I basically never want my app to the one playing the music. I just want the ability to get status and be a remote. So load the current song info, and progression, and then control play/pause next/previous.

Apart form that I have been seeing some issues keeping connected and reconnecting to the API. I do my initial auth process, it gets redirected to the spotify app and back perfectly fine. Then if music is paused for more than 30 seconds I get disconnected. Based on responses to previous issues this is intended behavior. However what comes next certainly can not be. I have that authorization code form the first auth process, its at this point less than a minute old.

appRemote.connectionParameters.accessToken = accessToken appRemote?.connect()

And I get a couple errors

`TCP Conn 0x280ea9720 Failed : error 0:61 [61]

Failed connection attempt with error: Error Domain=com.spotify.app-remote.transport Code=-2000 "Stream error." UserInfo={NSLocalizedDescription=Stream error., NSUnderlyingError=0x28313bcf0 {Error Domain=NSPOSIXErrorDomain Code=61 "Connection refused" UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, NSLocalizedRecoverySuggestion=Reconnect the transport to the Spotify app., NSLocalizedFailureReason=A stream error has occured in the transport.}`

This means in order to use the app as a remote. Every single time I want to play/pause I have to do a auth request and get bounced to the spotify app. And then reset the device the audio is coming from.