2013-10-18 50 views
1

我在我的應用程序中集成了soundCloud api。我正在使用以下代碼播放soundCloud歌曲,就像那裏提供的api文檔一樣。SoundCloud音軌在iPhone中播放太多時間播放

 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]; 
       } 
      }]; 

但問題是,它需要太多的時間來播放歌曲,它只是荒謬的。搜索後,我發現它首先下載曲目,然後播放。有沒有什麼方法可以一步一步地流式傳輸。任何幫助將不勝感激。謝謝。

回答

0

您必須在某段時間之前使用[player preparetoPlay]。

+0

我已經使用它但沒有運氣。 –

1

如果您要流式傳輸音頻,則應使用AVPlayer