简体   繁体   English

如何在iOS应用中播放Soundcloud音乐?

[英]How to play soundcloud music in ios app?

I'm trying to play music from my profile in soundcloud, I downloaded sounCloud API project, but it looks very difficult, maybe exist easiest way? 我正在尝试从soundcloud中的个人资料播放音乐,我下载了sounCloud API项目,但看起来很困难,也许是最简单的方法? Help me please. 请帮帮我。 Thank you. 谢谢。

You should be able to make a GET request for the track you're trying to play: 您应该能够对要播放的曲目发出GET请求:

[api performMethod:@"GET" 
        onResource:@"tracks" 
    withParameters:[NSDictionary dictionaryWithObject:@"12821506"  forKey:@"ids"] 
           context:context userInfo:nil];

You can then register a SCSoundCloudAPIDelegate and implement: 然后,您可以注册SCSoundCloudAPIDelegate并实现:

- (void)soundCloudAPI:(SCSoundCloudAPI *)soundCloudAPI 
    didFinishWithData:(NSData *)data 
              context:(id)context 
             userInfo:(id)userInfo;

If the context is equal to the context you passed in when making the GET request, you know your request is complete. 如果上下文等于在发出GET请求时传递的上下文,则说明您的请求已完成。 You can build an NSDictionary modeling the response, and then grab the stream URL for streaming: 您可以构建一个对响应建模的NSDictionary,然后获取流URL进行流传输:

NSDictionary *trackInfo = [data objectFromJSONData];
NSString *steamURL = [trackInfo objectForKey:@"stream_url];

The full list of parameters you can specify when making the GET request is available here . 您可以在发出GET请求时指定的参数的完整列表在此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM