IOS 7 Can't have audio through bluetooth receiver using AVAudioSession

I am having a problem using bluetooth for my iOS 7 app. To be more precise, the bluetooth receiver I would like to connect to is: http://www.amazon.co.uk/Sony-Bluetooth-Receiver-Enhancement -Smartphone-Black / dp / B00G9YK7LS

Of course, the iPhone connects to the device prior to testing.

My application should just do the audio pass (from microphone to speakers) using the EZAudio environment. It works fine with an iPhone headset, but not with Bluetooth.

Here's the code I put into the delegate class (didFinishLaunchingWithOptions function) to start the audio session:

// configure the audio session
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
NSError *err = NULL;

// deactivate session
[audioSession setActive:NO error:&err];
if (err) {
    NSLog(@"There was an error deactivating the audio session");
}

[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionAllowBluetooth error:&err];
if( err ){
    NSLog(@"There was an error creating the audio session");
}

[audioSession overrideOutputAudioPort:AVAudioSessionPortOverrideNone error:&err];
if( err ){
    NSLog(@"There was an error sending the audio to the speakers");
}

// Activate the session
[audioSession setActive:YES error:&err];

      

Then I use the EZAudio framework to send audio to the audio device:

/**
 Start the output
 */
[EZOutput sharedOutput].outputDataSource = self;
[[EZOutput sharedOutput] startPlayback];

      

Anyone have any ideas on this issue? Did I miss something?

Thank you for your help!

+3


source to share


1 answer


You must set the category AVAudioSessionCategoryPlayback

. If you have it set AVAudioSessionCategoryPlayAndRecord

, the Bluetooth device should be available for both input and output. If this is not the case, the device will by default use the internal speakers for playback.



+1


source







All Articles