错误Domain = com.spotify.ios-sdk.playback代码= 1“由于未指定的问题导致操作失败。” UserInfo = {NSLocalizedDescription =由于未指定的问题导致操作失败
这是我的代码
func getAlbums(authSession:SPTSession){
SPTPlaylistList.playlists(forUser: authSession.canonicalUsername, withAccessToken: authSession.accessToken) { (error, response) in
if let listPage = response as? SPTPlaylistList, let albums = listPage.items as? [SPTPartialPlaylist]{
for item in albums{
let stringFromUrl = item.uri
// use SPTPlaylistSnapshot to get all the playlists
print("************************\(item.name)************************")
SPTPlaylistSnapshot.playlist(withURI: stringFromUrl, accessToken: authSession.accessToken!) { (error, snap) in
if let s = snap as? SPTPlaylistSnapshot {
print("====================\(s.name)=====================")
// get the tracks for each playlist
SpotifyManager.MyAlbums.append(s)
if SpotifyManager.MyAlbums.count == albums.count{
NotificationCenter.default.post(name: NSNotification.Name(rawValue: relodNotification), object: nil)
}
}
}
}
}
}
}
此错误来自此方法
@objc func play() {
print(songInfo.uri)
SpotifyManager.player?.playSpotifyURI(self.songInfo.uri.absoluteString, startingWith: 0, startingWithPosition: 0, callback: { (err) in
print(err.debugDescription)
})
}
如果有人遇到此类问题,请给我一个在我的应用中播放Spotify音乐的最佳解决方案。
答案 0 :(得分:0)
只需删除循环,因为播放器会自动为您执行此操作!