我正在尝试在 soundcloud 中播放我的个人资料中的音乐,我下载了 soundcloud API 项目,但它看起来非常困难,也许存在最简单的方法?请帮帮我。谢谢你。
问问题
2150 次
1 回答
0
您应该能够为您尝试播放的曲目发出 GET 请求:
[api performMethod:@"GET"
onResource:@"tracks"
withParameters:[NSDictionary dictionaryWithObject:@"12821506" forKey:@"ids"]
context:context userInfo:nil];
然后,您可以注册 SCSoundCloudAPIDelegate 并实现:
- (void)soundCloudAPI:(SCSoundCloudAPI *)soundCloudAPI
didFinishWithData:(NSData *)data
context:(id)context
userInfo:(id)userInfo;
如果上下文等于您在发出 GET 请求时传入的上下文,则您知道您的请求已完成。您可以构建一个 NSDictionary 对响应进行建模,然后获取流 URL 以进行流式传输:
NSDictionary *trackInfo = [data objectFromJSONData];
NSString *steamURL = [trackInfo objectForKey:@"stream_url];
发出 GET 请求时可以指定的完整参数列表可在此处获得。
于 2011-05-13T18:13:32.327 回答