【问题标题】:SoundCloud tracks take too much time play in iPhoneSoundCloud 曲目在 iPhone 中播放时间过长
【发布时间】:2013-10-18 07:42:39
【问题描述】:

我在我的应用程序中集成了 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];
                 }
             }];

但问题是播放歌曲需要太多时间,而且太荒谬了。经过搜索,我发现它首先下载了曲目,然后播放。有什么办法可以一步一步来。任何帮助将不胜感激。谢谢。

【问题讨论】:

    标签: ios streaming avaudioplayer soundcloud


    【解决方案1】:

    如果你想流式传输音频,你应该使用AVPlayer

    【讨论】:

      【解决方案2】:

      您必须在玩一段时间之前使用 [player preparetoPlay]。

      【讨论】:

        猜你喜欢
        • 2013-03-21
        • 1970-01-01
        • 2013-03-11
        • 1970-01-01
        • 1970-01-01
        • 2020-06-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多