[英]iOS stream Audio and record Audio
i have an app which should record audio when a button i pressed.我有一个应用程序,当我按下按钮时,它应该录制音频。 In my ViewDidLoad i preapare the recorder, the problem is that streaming audio interrupts when the line 'self.audioRecorder.prepareToRecord()' is called.
在我的 ViewDidLoad 中,我准备了录音机,问题是当调用“self.audioRecorder.prepareToRecord()”行时流式音频中断。
My setup :我的设置:
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)
}
is there a way to preapare the audio recorder for record, and continue to play audio in background ?有没有办法准备录音机进行录音,并在后台继续播放音频? (duck it when recording the audio)
(录制音频时将其隐藏)
Per Apple's documentation for AVAudioSessionCategoryRecord , "this category silences playback audio".根据Apple 的 AVAudio Session Category Record 文档,“此类别使播放音频静音”。 Have you tried setting the category to
AVAudioSessionCategoryPlayAndRecord
?您是否尝试将类别设置为
AVAudioSessionCategoryPlayAndRecord
?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.