[英]SoundCloud tracks take too much time play in iPhone
我已經在我的應用程序中集成了soundCloud api。我正在使用api文檔中提到的以下代碼播放soundCloud歌曲。
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];
}
}];
但是問題在於,播放歌曲需要太多時間,而且太荒謬了。 搜索后,我發現它首先下載了曲目,然后播放了。 有什么辦法可以分步流式傳輸。 任何幫助將不勝感激。 謝謝。
如果要流式傳輸音頻,則應使用AVPlayer 。
您必須在游戲開始前使用[player preparetoPlay]。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.