Reputation: 2705
I am recording audio in a view controller and displaying a button for the user to play it on a second view controller.
The thing is that I am using this code on the second view so the audio can be played even on silent mode:
UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
AudioSessionSetProperty (kAudioSessionProperty_AudioCategory,
sizeof(sessionCategory), &sessionCategory);
But when I go back to record a second audio, it does not play on the second screen.
Any leads on this? Seems like I have to change those settings again to its originals.
Upvotes: 1
Views: 377
Reputation: 5175
Try this:
UInt32 sessionCategory = kAudioSessionCategory_PlayAndRecord;
AudioSessionSetProperty (kAudioSessionProperty_AudioCategory,
sizeof(sessionCategory), &sessionCategory);
Some time ago I had the similar issue, but I was using AVAudioSession. The problem was the same, then I found one thing, it may be usefull for you:
record was working fine, then after I playback something it stop working at all. The problem was I resetedup AVAudioSession to playback category by calling
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
after that recording stop working. There is a two ways to fix it, setup audio session defire recording to AVAudioSessionCategoryRecord
and before playback to AVAudioSessionCategoryPlayback
or setup with AVAudioSessionCategoryPlayAndRecord
.
after I did
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
everything started to work fine.
Upvotes: 2