GarySabo
GarySabo

Reputation: 6710

Using the Spotify SDK in iOS using Swift 3.0

Spotify's beginner tutorial is only in Objective-C https://developer.spotify.com/technologies/spotify-ios-sdk/tutorial/, but using this along with this video: https://www.youtube.com/watch?v=GeO00YdJ3cE I was able to get my development environment set up properly, however the SDK's methods (stuck on log in) have changed since that video was posted...can anyone tell me how to convert the log in methods into Swift?

I'll be happy to open source my code once i get it running.

Upvotes: 0

Views: 1572

Answers (1)

Flyte27
Flyte27

Reputation: 53

Here's a great tutorial on implementing the iOS Spotify SDK in Swift. Without looking at your code, what you're looking for is likely the following:

if player == nil {
    self.player = SPTAudioStreamingController.sharedInstance()

    self.player!.playbackDelegate = self
    self.player!.delegate = self
    try! player!.start(withClientId: auth.clientID)
    self.player!.login(withAccessToken: session.accessToken)
}

This will then call the following delegate function when the login returns:

func audioStreamingDidLogin(_ audioStreaming: SPTAudioStreamingController!) {

}

Once that delegate function is called you can start using the player to play tracks.

Upvotes: 2

Related Questions