I have a project in which I have to record the voice coming from the Bluetooth headset and play with the iPhone speaker by default. I searched a lot and got this code.
UInt32 allowBluetoothInput = 1; AudioSessionSetProperty ( kAudioSessionProperty_OverrideCategoryEnableBluetoothInput, sizeof (allowBluetoothInput), &allowBluetoothInput );
------------ CODE FOR AUDIO RECORDER START AND STOP ------------
- (IBAction)Record: (id)sender { UIButton *btn = (UIButton *)sender; if([btn isSelected]) { [audioRecorder stop]; [btn setSelected:NO]; [btn setTitle:@"Start Recording" forState:UIControlStateNormal]; } else { [audioRecorder record]; [btn setSelected:YES]; [btn setTitle:@"Stop Recording" forState:UIControlStateNormal]; } }
and after that I use avaudiorecorder. It seems to me that something else is missing here.
-------- Code for audio recordings ---------
NSURL *soundFileURL = [NSURL fileURLWithPath:AUDIO_FILE]; NSDictionary *recordSettings = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:AVAudioQualityMin], AVEncoderAudioQualityKey, [NSNumber numberWithInt:16], AVEncoderBitRateKey, [NSNumber numberWithInt: 2], AVNumberOfChannelsKey, [NSNumber numberWithFloat:44100.0], AVSampleRateKey, nil]; NSError *error = nil; audioRecorder = [[AVAudioRecorder alloc] initWithURL:soundFileURL settings:recordSettings error:&error]; if (error) { NSLog(@"error: %@", [error localizedDescription]); } else { [audioRecorder prepareToRecord]; }
I think I am missing something else that needs to be added here. I just want Bluetooth audio input garnishing to connect. Any help would be appreciated.
Thanks at Advance !!
source share