【发布时间】:2023-03-11 07:45:01
【问题描述】:
Error Domain=com.spotify.ios-sdk.playback Code=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 音乐的最佳解决方案。
【问题讨论】:
-
你通过循环重复列表,而没有循环,播放器获取列表并自行处理循环