简体   繁体   English

iPhone音频流

[英]iphone audio streaming

i'm developing an application which uses audio streaming. 我正在开发一个使用音频流的应用程序。 For streaming audio from internet i'm using the AudioStreamer class. 为了从互联网流式传输音频,我使用了AudioStreamer类。 The audio streamer has four state isPlaying, isPaused ,isWaiting, and isIdle . 音频流媒体具有四个状态isPlaying,isPaused,isWaiting和isIdle。 My problem is that when the audio streamer is in the state "isWaiting" and at that time if i get a phone call Audio queue fails giving the error "Audio queue start failed." 我的问题是,当音频流媒体处于“正在等待”状态时,并且如果我接到电话,音频队列将失败,并显示错误“音频队列启动失败”。 Any has solution for this? 有解决办法吗? help.... 救命....

An interruption - such as receiving a call - will deactivate the Audio Session. 中断(例如接听电话)将停用音频会话。 It's up to you to, in your interruption handler, re-activate the Audio Session by calling AudioSessionSetActive(true). 在中断处理程序中,您可以通过调用AudioSessionSetActive(true)重新激活音频会话。

Look here for details of the interruption handler. 在此处查看有关中断处理程序的详细信息。

Having said that, I'll assume that you're using mattgallagher's library . 话虽如此,我假设您正在使用mattgallagher的库 The thing to do is put a breakpoint in AudioStreamer.m on line 949 (the line after "err = AudioQueueStart(audioQueue, NULL);" in -[AudioStreamer pause]. 要做的事情是在949行(在-[AudioStreamer暂停]中的“ err = AudioQueueStart(audioQueue,NULL);”之后的行)上的AudioStreamer.m中放置一个断点。

If err == kAudioSessionNotActiveError then my theory's right, and you need to call restart the audio session. 如果err == kAudioSessionNotActiveError,那么我的理论是对的,您需要调用重新启动音频会话。 Perhaps something like this (but I've only only ever glanced through this code so perhaps there's a better way of solving the problem): 也许是这样的(但是我只看过这段代码,所以也许有解决问题的更好方法):

else if (state == AS_PAUSED)
{
  err = AudioQueueStart(audioQueue, NULL);
  if (err) {
    err = AudioSessionSetActive(true);
    if (err) {
      [self failWithErrorCode:AS_AUDIO_QUEUE_START_FAILED];
      return;
    } else {
      err = AudioQueueStart(audioQueue, NULL);
      if (err) {
        [self failWithErrorCode:AS_AUDIO_QUEUE_START_FAILED];
        return;
      }
    }
  }
}

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

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