阅读背景:

SoundCloud跟踪在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.

但问题是,播放歌曲花了太多时间,这太荒谬了。搜索之后,我发现它先下载了音轨,然后播放了。有什么方法可以一步一步地流吗?如有任何帮助,我们将不胜感激。谢谢。

2 个解决方案

#1


1  

You should use AVPlayer if you want to stream audio.

如果你想要播放音频,你应该使用AVPlayer。

#2


0  

You have to use [player preparetoPlay] before some time of play.

在比赛开始前,你必须使用[运动员准备]。


分享到: