使用预缓冲区在iOS中开始播放SoundCloud音频流
使用SoundCloud开发者页面中的以下代码示例,AVAudioPlayer将在收到SCRequest响应后开始播放。根据请求文件的大小,这可能需要一些时间。使用预缓冲区在iOS中开始播放SoundCloud音频流,ios,soundcloud,Ios,Soundcloud,使用SoundCloud开发者页面中的以下代码示例,AVAudioPlayer将在收到SCRequest响应后开始播放。根据请求文件的大小,这可能需要一些时间。iOS SoundCloud API是否提供预缓冲解决方案,以便在接收到所有数据之前开始播放音频,或者我是否需要在NSURLConnection的帮助下实施自己的解决方案以实现这一点 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPat
iOS SoundCloud API是否提供预缓冲解决方案,以便在接收到所有数据之前开始播放音频,或者我是否需要在NSURLConnection的帮助下实施自己的解决方案以实现这一点
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSDictionary *track = [self.tracks objectAtIndex:indexPath.row];
NSString *streamURL = [track objectForKey:@"stream_url"];
SCAccount *account = [SCSoundCloud account];
[SCRequest performMethod:SCRequestMethodGET
onResource:[NSURL URLWithString:streamURL]
usingParameters:nil
withAccount:account
sendingProgressHandler:nil
responseHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
NSError *playerError;
player = [[AVAudioPlayer alloc] initWithData:data error:&playerError];
[player prepareToPlay];
[player play];
}];
}
afaik目前没有预缓冲解决方案。如果您想为我们的SoundCloud API做出贡献,我们希望查看您关于此功能的请求 这很可能会影响到和
快乐编码 要从SoundCloud流式播放曲目,只需将URL传递给具有客户端id的AVPlayer:
NSString *urlString = [NSString stringWithFormat:@"%@?client_id=%@", track.streamURL, self.clientId];
player = [[AVPlayer alloc] initWithURL:[NSURL URLWithString:urlString]];
[player play];
这将需要一些额外的工作,使它成为一个渐进的下载。希望这能有所帮助。您有解决此问题的方法吗?任何方法我也遇到了相同的问题。任何方法我也遇到了相同的问题。如果他们真的需要,他们必须使用类似STKAudioPlayer的方法,在播放之前获取缓冲区,并将PCM格式的缓冲区保存到文件中。谢谢。这比SoundCloud的其他SDK的API指南中描述的带有
allow_redirects=False的GET请求要简单得多。