I have integrated soundCloud api in my application.I am playing soundCloud songs using following code as mentioned on there api documentation.
NSString *urlString = [NSString stringWithFormat:@"%@?client_id=%@",actiVityObj.songUrl, @"e0b860d9584b7194183a9e797dc0fc16"];
[SCRequest performMethod:SCRequestMethodGET
onResource:[NSURL URLWithString:urlString]
usingParameters:nil
withAccount:nil
sendingProgressHandler:nil
responseHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
NSError *playerError;
audioPlayer = [[AVAudioPlayer alloc] initWithData:data error:&playerError];
audioPlayer.numberOfLoops = 0;
audioPlayer.volume = 1.0f;
audioPlayer.delegate = self;
[audioPlayer prepareToPlay];
if (audioPlayer == nil)
{
}
else
{
[audioPlayer play];
}
}];
But problem is that it takes too much time to play song and it just ridiculous. After searching I found it first download the track and then it played. Is there any way to stream it step by step. Any help will be appreciated. Thanks.
如果要流式传输音频,则应使用AVPlayer 。
您必须在游戏开始前使用[player preparetoPlay]。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.