AVAudioRecorder - Proper MPEG4 AAC Recording Settings

前端 未结 3 799
悲&欢浪女
悲&欢浪女 2021-02-06 04:52

I\'ve got a live app with an estimated 15% of users reporting that the record feature is not working. This isn\'t happening on our test devices, but the reports show that the p

3条回答
  •  梦毁少年i
    2021-02-06 05:35

    Apologies that this is slightly tangential but I've just had a very similar issue with a number of users not being able to record, which I thought was related to audio settings.

    However for me it turned out that they had denied permission to access the microphone. This meant that prepareToRecord was working (and truncating the file) and record was reporting that it was working, but actually it wasn't recording anything.

    And I used this when I want to record:

    AVAudioSession.sharedInstance().requestRecordPermission({(granted: Bool)-> Void in
        if granted {
            // can record - create AVAudioRecorder here
    
        } else {
            // can't record - update UI (or react accordingly)
        }
    })
    

    Hope it saves someone some time if they run into a similar issue.

提交回复
热议问题