Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS-AudioKit在接到电话时崩溃_Ios_Swift_Avaudiosession_Audiokit_Avaudiorecorder - Fatal编程技术网

iOS-AudioKit在接到电话时崩溃

iOS-AudioKit在接到电话时崩溃,ios,swift,avaudiosession,audiokit,avaudiorecorder,Ios,Swift,Avaudiosession,Audiokit,Avaudiorecorder,音频套件4.9.3 iOS 11+ 我正在做一个项目,用户使用麦克风在设备上录音,即使应用程序在后台,它也会继续录音。这很好,但当我接到电话时,我会收到一个音频套件错误。我想这与手机接管麦克风或其他东西有关。以下是错误: [avae]AVAEInternal.h:109 [AVAudioEngineGraph.mm:1544:Start:(err=PerformCommand(*ioNode, kAUStartIO,NULL,0)):错误561017449 AudioKit+StartStop.

音频套件4.9.3 iOS 11+

我正在做一个项目,用户使用麦克风在设备上录音,即使应用程序在后台,它也会继续录音。这很好,但当我接到电话时,我会收到一个音频套件错误。我想这与手机接管麦克风或其他东西有关。以下是错误:

[avae]AVAEInternal.h:109
[AVAudioEngineGraph.mm:1544:Start:(err=PerformCommand(*ioNode, kAUStartIO,NULL,0)):错误561017449 AudioKit+StartStop.swift:路由更改后重新启动(:):198:错误 更改路线后重新启动发动机

基本上,我所记录的所有东西都丢失了

以下是我的设置音频套件代码:

func configureAudioKit() {
        AKSettings.audioInputEnabled = true
        AKSettings.defaultToSpeaker = true
        do {
            try try audioSession.setCategory((AVAudioSession.Category.playAndRecord), options: AVAudioSession.CategoryOptions.mixWithOthers)
            try audioSession.setActive(true)
            audioSession.requestRecordPermission({ allowed in
                DispatchQueue.main.async {
                    if allowed {
                        print("Audio recording session allowed")
                        self.configureAudioKitSession()
                    } else {
                        print("Audio recoding session not allowed")
                    }
                }
            })
        } catch let error{
            print("Audio recoding session not allowed: \(error.localizedDescription)")
        }
    }


func configureAudioKitSession() {
        isMicPresent = AVAudioSession.sharedInstance().isInputAvailable
        if !isMicPresent {
            return
        }
        print("mic present and configuring audio session")
        mic = AKMicrophone()
        do{
        let _ = try AKNodeRecorder(node: mic)
        let recorderGain = AKBooster(mic, gain: 0)
        AudioKit.output = recorderGain
        //try AudioKit.start()
        }
        catch let error{
            print("configure audioKit error: ", error)
        }
}
当点击记录按钮代码时:

    do {
         audioRecorder = try AVAudioRecorder(url: actualRecordingPath, settings: audioSettings)
         audioRecorder?.record()
         //print("Recording: \(isRecording)")
         do{
           try AudioKit.start()
          }
          catch let error{
            print("Cannot start AudioKit", error.localizedDescription)
          }
}
当前音频设置:

private let audioSettings = [
        AVFormatIDKey : Int(kAudioFormatMPEG4AAC),
        AVSampleRateKey : 44100,
        AVNumberOfChannelsKey : 2,
        AVEncoderAudioQualityKey : AVAudioQuality.medium.rawValue
    ]
如何确保即使在接到电话时也能获得正确的录音?无论您选择接听还是拒绝,错误都会在接到电话后立即发生


有什么想法吗?

AudioKit只处理音频播放应用程序的基本路由更改处理。我们发现,当应用程序变得足够复杂时,框架无法有效地预测发生中断时的适当操作过程。因此,我建议关闭AudioKit的路由更改处理并响应你自己


另外,我会在按钮中输入音频套件激活码。

我已经完成了这方面的工作,在通话或VOIP通话过程中,恐怕您无法访问麦克风


这是iOS出于不言而喻的原因强制实施的基本隐私措施。

只是好奇:如果您在audioSession的
设置类别
呼叫中添加
.mixWithOthers
选项,崩溃还会发生吗?@WongWray是的,它会发生-我也尝试过,尽管我现在已经将它保留在mixWithOthers中(上面更新的代码).我目前正在试着看看如何处理这种干扰。