ios: Make it easier to play media and record audio simultaneously
close #17
diff --git a/src/ios/CDVSound.m b/src/ios/CDVSound.m
index 0dad4a6..7370026 100644
--- a/src/ios/CDVSound.m
+++ b/src/ios/CDVSound.m
@@ -555,7 +555,10 @@
}
// get the audioSession and set the category to allow recording when device is locked or ring/silent switch engaged
if ([self hasAudioSession]) {
- [self.avSession setCategory:AVAudioSessionCategoryRecord error:nil];
+ if (![self.avSession.category isEqualToString:AVAudioSessionCategoryPlayAndRecord]) {
+ [self.avSession setCategory:AVAudioSessionCategoryRecord error:nil];
+ }
+
if (![self.avSession setActive:YES error:&error]) {
// other audio with higher priority that does not allow mixing could cause this to fail
errorMsg = [NSString stringWithFormat:@"Unable to record audio: %@", [error localizedFailureReason]];