AVAudioEngine.connect crash on hardware not simulator

后端 未结 1 980
渐次进展
渐次进展 2021-01-20 10:13
var engine:AVAudioEngine!
var format = engine.inputNode.inputFormat(forBus: 0)
engine.connect(engine.inputNode, to: engine.mainMixerNode, format: format)


        
相关标签:
1条回答
  • 2021-01-20 11:08

    I figure it out. I just set the AVAudioSession category type wrong. If you have the same error take a look at AVAudioSession and make sure that your AVAudioSession category is in the right setting for microphone permission. for instance

    AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord, with: .mixWithOthers)
    

    with this setting will allow app to use microphone and play sound in the same time.

    0 讨论(0)
提交回复
热议问题