【发布时间】:2014-03-21 12:20:11
【问题描述】:
我正在尝试使用 spotify API 获取艺术作品或专辑封面。我正在使用:
NSString *url = @"http://ws.spotify.com/search/1/track.json";
NSMutableDictionary *params = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
([Utils isEmptyString:_searchBar.text] ? @"music" : _searchBar.text), @"q", nil];
[self sendRequestWith:url params:params method:RequestMethodGET success:^(AFHTTPRequestOperation *operation, id response, NSDictionary *userData) {
NSDictionary *result = (NSDictionary *)response;
if(result){
[_trackList removeAllObjects];
NSArray *tracks = [Utils getDictionaryValue:result by:@[@"tracks"]];
for (NSDictionary *trackData in tracks) {
WPTrack *track = [[WPTrack alloc] initWithSpotifyJSON:trackData];
[_trackList addObject:track];
}
[listViewController updateWithObjects:_trackList];
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error, NSDictionary *userData) {
} userData:nil];
我得到的当前方法似乎没有返回曲目的缩略图。但它会返回曲目的“href”,我可以使用它来通过https://embed.spotify.com/oembed/?url=spotify:track:6bc5scNUVa3h76T9nvpGIH 搜索曲目的图像。但是,这可能是另一个请求,它可能会减慢我在 UITableView 上的加载速度。有没有更好的方法一起完成这个过程?
【问题讨论】:
标签: ios spotify libspotify