gpt4 book ai didi

ios - 在我的 iOS 应用程序中播放 Spotify 播放列表或专辑音乐

转载 作者:行者123 更新时间:2023-11-30 11:50:15 25 4
gpt4 key购买 nike

Error Domain=com.spotify.ios-sdk.playback Code=1 "The operation failed due to an unspecified issue." UserInfo={NSLocalizedDescription=The operation failed due to an unspecified issue

这是我的代码

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 音乐的最佳解决方案。

最佳答案

只需删除循环即可,因为播放器会自动为您执行此操作!

关于ios - 在我的 iOS 应用程序中播放 Spotify 播放列表或专辑音乐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48395180/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com