views:

160

answers:

1

I am trying to write an application where the user records a sound and would be listening to the same with a background music from music library. However, when i try to play the recorded file using AVAudioplayer, the background music (iPod Player) is going very low and not audible. Is there any session property i need to set for playing both the AVAudioPlayer and the iPod player at the same level? I have tried to put allowMixing property but no success..

A: 

Here is the code for setting . May be i missed out something.

[audioSession setCategory :AVAudioSessionCategoryPlayAndRecord error:&err];
    UInt32 category = 1;





    AudioSessionSetProperty( kAudioSessionProperty_OverrideCategoryMixWithOthers , sizeof( category ) , &category );

    UInt32 doChangeDefaultRoute = 1;
        OSStatus status;
    if (status = AudioSessionSetProperty( kAudioSessionProperty_OverrideCategoryDefaultToSpeaker,
                                         sizeof(doChangeDefaultRoute), &doChangeDefaultRoute)) {
        NSLog(@"RunSketchAppDelegate: ERROR: couldn't set kAudioSessionProperty_OverrideCategoryDefaultToSpeaker to %i. Error code = %i", doChangeDefaultRoute, status);
    } else {
        NSLog(@"RunSketchAppDelegate: successfully set kAudioSessionProperty_OverrideCategoryDefaultToSpeaker to %i", doChangeDefaultRoute);
    }

Hope that helps.. I am still getting the playback lovering.

Nareshkumar