GusDev
GusDev

Reputation: 297

Can`t play a song Spotify SDK

I want to play some songs from Spotify, I just have the login section, I get the token and everything but I can't play any song.

I have followed this tutorial (http://sonien.net/wordpress/using-spotify-ios-sdk-swift-ios-9/) and I have some errors.

1.- Argument passed to call that takes no arguments

self.player = SPTAudioStreamingController.init(clientId: SPTAuth.defaultInstance().clientID)

2.- Value of type 'SPTAudioStreamingController' has no member 'loginWithSession'

player.loginWithSession(session, callback: self.didLogin)

so I changed to:

player.login(withAccessToken: String(session))

and I think i solved the error

I'm using Swift 3 with Xcode 8

Upvotes: 0

Views: 414

Answers (1)

Angel
Angel

Reputation: 19

I ran into a similar problem with initializing an instance of the SPTAudioStreamingController. This is because the SDK requires that you init a SharedInstance of the object first before you can access any of its methods. This is because the SPTAudioStreamingController class is a Singleton class, meaning it can only be instantiated once throughout the lifetime of the application.

The proper syntax for this in the SDK is:

player = SPTAudioStreamingController.sharedInstance()

Hope this was helpful!

Upvotes: -1

Related Questions