提供播放流的代码如下:
SCAccount *account = [ScsoundCloud account]; [SCRequest performMethod:SCRequestMethodGET onResource:[NSURL URLWithString:audiofile] usingParameters:nil withAccount:account sendingProgressHandler:nil responseHandler:^(NSURLResponse *response,NSData *data,NSError *error) { NSError *playerError; audioPlayer = [[AVAudioPlayer alloc] initWithData:data error:&playerError]; audioPlayer.numberOfLoops = 0; [audioPlayer preparetoPlay]; [audioPlayer play]; }];
问题:有没有一种方法可以播放SoundCloud文件而无需先登录到您的SoundCloud帐户?我们希望所有用户都考虑使用SoundCloud – 但是,如果新用户之前可以收听多个曲目,那么可用性是有用的.
解决方法 要使用IOS Soundcloud SDK进行公共访问,您需要将Soundcloud clIEntID作为参数添加到请求字符串中:Nsstring *urlString = [Nsstring stringWithFormat:@"%@?clIEnt_ID=%@",publicTrackUrlString,yourScclIEntID];[SCRequest performMethod: SCRequestMethodGET onResource: [NSURL URLWithString:urlString] usingParameters: nil withAccount: nil sendingProgressHandler: nil responseHandler:^(NSURLResponse *response,NSError *error){ // }];
然后,当withAccount:参数为nil时,它将适用于公共轨道.
更优雅的是,你可以将“clIEnt_ID”打包在字典中并与usingParameters一起使用:
NSDictionary * params = @ {@“clIEnt_ID”:yourScclIEntID};
总结以上是内存溢出为你收集整理的在IOS应用程序中播放SoundCloud文件全部内容,希望文章能够帮你解决在IOS应用程序中播放SoundCloud文件所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)