在我的应用程序中,我会立即录制并播放录制的声音:
func finishRecording(success: Bool) {
audioRecorder.stop()
audioRecorder = nil
let audioSession = AVAudioSession.sharedInstance()
do {
try audioSession.setCategory(AVAudioSessionCategoryAudioProcessing)
try audioSession.setActive(false)
playSound(url: audioFilename!)
...
func playSound(url : URL) {
do {
let engine = AVAudioEngine()
let newPlayer = AVAudioPlayerNode()
engine.attach(newPlayer)
let mainMixer = engine.mainMixerNode
最后一行打印错误: 错误:[0x1a07d0000]> aurioc> 807:失败:'!cat'(启用2,outf< 2 ch,0 Hz,Float32,非inter> inf< 2 ch,0 Hz,Float32,非inter>)
据我所知,由于输入节点仍在使用中,因此会发生此错误。我不确定我应该怎么做才能使用mainMixerNode初始化AVAudioPlayerNode? p>
(如果我杀了应用程序并用我的播放功能播放录制的声音,它可以正常工作)