record example can't record (iOS)

Hello, when I use fmod record library run in iOS, it throw a error, and can’t continue to play in this code:

result = system->recordStart(DEVICE_INDEX, sound, true);

it sounds like can’t record, my iOS version is iOS11, hope some one can help me to solve this problem, it is appreciate!

Have you setup the AudioSession category correctly?

Recording Much like lock screen and background audio, recording requires a particular AudioSession category to be active at the time of System::recordStart (and must remain active until the recording finishes). The required category is called 'play and record' and can be read about in the audio session basics documentation. Note that FMOD is always 'playing' audio (even silence) so it is not sufficient to simply use the 'recording' category unless you are running the 'No Sound' or 'Wav Writer' output mode.

Some devices may take some time to switch AudioSession category so it is recommended to set this category at application start time to avoid any hiccups in audio playback.

https://fmod.com/resources/documentation-api?page=content/generated/platform_ios/basics.html#/
1 Like

that’s right!thank you very much!

add this code:
[session setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];