问题
I am developing an music App using Swift3 language. Where user will have popup option to show the list of Songs using Music Library & Spotify. I can able to display the song lists from Music Library to my tableview. Now I have to get the playlists from Spotify. So, I added the App in accounts.spotify.com
and I can play the songs one by one using SPTAudioStreamingController.sharedInstance().metadata
but full song lists are not coming.
I follow this links: https://github.com/Sethmr/SpotifyInSwift & https://medium.com/@elonrubin/ios-spotify-sdk-swift-3-0-tutorial-b629af4b889d & https://developer.spotify.com/technologies/spotify-ios-sdk/tutorial/
The problem is How can I get the list of Spotify Songs. If anyone have some idea, please suggest me. Thank You!
回答1:
There is one more to try here
There are some more controls
Get an album:
_ = Spartan.getAlbum(id: albumId, market: .us, success: { (album) in
// Do something with the album
}, failure: { (error) in
print(error)
})
Get several tracks:
_ = Spartan.getTracks(ids: trackIds, market: .us, success: { (tracks) in
// Do something with the tracks
}, failure: { (error) in
print(error)
})
Try it, may help you https://github.com/Daltron/Spartan
Also go through this answer(Samantha's)
SPTPlaylistList.playlists(forUser: session.canonicalUsername, withAccessToken: session.accessToken, callback: { (error, response) in
self.activityIndicator.stopAnimating()
if let listPage = response as? SPTPlaylistList, let playlists = listPage.items as? [SPTPartialPlaylist] {
self.playlists = playlists // or however you want to parse these
self.tableView.reloadData()
if listPage.hasNextPage {
self.getNextPlaylistPage(currentPage: listPage)
}
}
})
Update :
Refer this sample code also
来源:https://stackoverflow.com/questions/47813383/how-to-get-the-list-of-songs-using-spotify-in-swift3-ios