views:

50

answers:

0

hello everyone,

I've got an issue which I need to solve

I am recording audio (caf) on the iPhone, then I need to play this after recording.

I am doing this all right on the Simulator but the problem is that on the device, the audio played's volume is really low as the only output is the iPhone's mic and not the iPhone Speaker

In the code, I'm initiating an AVAudioSession

AVAudioSession * audioSession = [AVAudioSession sharedInstance];

[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error: &error]; [audioSession setActive:YES error: &error];

then making some recording settings with an NSMutableDictionary

NSMutableDictionary* recordSetting = [[NSMutableDictionary alloc] init];

[recordSetting setValue:[NSNumber numberWithInt:kAudioFormatAppleIMA4] forKey:AVFormatIDKey]; [recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey]; [recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];

After I simply record the audio

recordedTmpFile = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent: [NSString stringWithFormat: @"%.0f.%@", [NSDate timeIntervalSinceReferenceDate] * 1000.0, @"caf"]]];
    recorder = [[AVAudioRecorder alloc] initWithURL:recordedTmpFile settings:recordSetting error:&error];
    [recorder setDelegate:self];
    [recorder prepareToRecord];
    [recorder record];
    [recorder recordForDuration:(NSTimeInterval) 18];
    [actSpinner stopAnimating];
    actSpinner.hidden = YES;

what should I do to let the Speaker on the iPhone work as well while playing the audio I've recorded ?

Please help me and thanks for answers