2016-06-28 6 views
0

ボタンを押したときに音声を録音するアプリがあります。私はレコーダーをpreapare私のviewDidLoadで は、問題はライン「self.audioRecorder.prepareToRecordは()」と呼ばれたときにオーディオをストリーミングすることは中断していることです。iOSストリーム音声と録音Audio

マイセットアップ:レコードのオーディオレコーダーをpreapare、バックグラウンドでオーディオを再生し続けるための方法が

do { 
    recordingSession = AVAudioSession.sharedInstance() 
    try recordingSession.setCategory(AVAudioSessionCategoryRecord, withOptions: [.DuckOthers, .AllowBluetooth, .MixWithOthers]) 

    recordingSession.requestRecordPermission() { [unowned self] (allowed: Bool) -> Void in 
     dispatch_async(dispatch_get_main_queue()) { 
      do { 
       if allowed { 
        self.audioRecorder = try AVAudioRecorder(URL: self.tempAudioPath, settings: self.settings) 
        self.audioRecorder.delegate = self 
        self.audioRecorder.prepareToRecord() 
        //self.audioRecorder.record() 
       } else { 
        // failed to record! 
        print("No Access to Micro") 
       } 
      }catch{} 
     } 
    } 
} catch { 
    print (error) 
} 

ありますか? 「このカテゴリには、再生音声を消音」、Apple's documentation for AVAudio​Session​Category​​Recordパー

+1

オーディオの再生中に録音するには、AudioUnitsを使用する必要があります。https://developer.apple.com/library/ios/documentation/MusicAudio/Conceptual/AudioUnitHostingGuide_iOS/AudioUnitHostingFundamentals/AudioUnitHostingFundamentals.html – SArnab

答えて

0

(それ鴨の音声を録音するとき)。カテゴリをAVAudio​Session​Category​Play​And​Recordに設定しようとしましたか?