简体   繁体   English

在iPhone中播放SoundCloud曲目需要花费太多时间

[英]SoundCloud tracks take too much time play in iPhone

I have integrated soundCloud api in my application.I am playing soundCloud songs using following code as mentioned on there api documentation. 我已经在我的应用程序中集成了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];
                 }
             }];

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]。

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

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