0
我有一個應用程序,它應該記錄音頻時,我按下了一個按鈕。 在我的ViewDidLoad我preapare錄音機,問題是流'音頻中斷時,'self.audioRecorder.prepareToRecord()'行被調用。iOS流音頻和記錄音頻
我的設置:
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)
}
是有辦法preapare備案錄音機,並繼續在後臺播放音頻? (在錄製音頻時將其放在其上)
在播放音頻時錄音涉及使用AudioUnits:https://developer.apple.com/library/ios/documentation/MusicAudio/Conceptual/AudioUnitHostingGuide_iOS/AudioUnitHostingFundamentals/AudioUnitHostingFundamentals.html – SArnab