gpt4 book ai didi

ios - 如何播放 Spotify 播放列表

转载 作者:行者123 更新时间:2023-11-29 01:46:41 25 4
gpt4 key购买 nike

我正确地检索了登录用户的 Spotify 播放列表:

- (IBAction)loadPlaylist{
SPTAuth *auth = [SPTAuth defaultInstance];
[SPTPlaylistList playlistsForUserWithSession:auth.session callback:^(NSError *error, id object) {
SPTListPage *pl= object;
NSLog(@"%@ my playlist items",pl.items);
}];
}

但是,我不明白如何开始播放这个播放列表。

最佳答案

检索所有播放列表并将其传递给玩家。

 [self.player loginWithSession:auth.session callback:^(NSError *error) {

if (error != nil) {
NSLog(@"*** Error occurred while trying to log in %@", error);
return;
}

[SPTPlaylistList playlistsForUserWithSession:auth.session callback:^(NSError *error, id object) {
if (!error) {
NSURL *playlistURL = nil;
SPTListPage *pl= object;

if(pl != nil && pl.items.count > 0)
playlistURL = [pl.items[1] uri];

NSURLRequest *playlistReq = [SPTPlaylistSnapshot createRequestForPlaylistWithURI:playlistURL accessToken:auth.session.accessToken error:nil];

[[SPTRequest sharedHandler] performRequest:playlistReq callback:^(NSError *error, NSURLResponse *response, NSData *data) {
if (error != nil) {
NSLog(@"*** Failed to get playlist %@", error);
return;
}

SPTPlaylistSnapshot *playlistSnapshot = [SPTPlaylistSnapshot playlistSnapshotFromData:data withResponse:response error:nil];

[self.player playURIs:playlistSnapshot.firstTrackPage.items fromIndex:0 callback:nil];
}];

}
}];

关于ios - 如何播放 Spotify 播放列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31843607/

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