IOS 7 Bluetooth output not working for AVAudioSessionCategoryPlayAndRecord

In my application, if the iPhone is connected to a Bluetooth headset, play the sound using Bluetooth. Else use the default speaker.

Here is my code

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionAllowBluetooth error:nil]; [[AVAudioSession sharedInstance] setMode:AVAudioSessionModeVoiceChat error:nil]; [[AVAudioSession sharedInstance] overrideOutputAudioPort:AVAudioSessionPortOverrideNone error:nil]; [[AVAudioSession sharedInstance] setActive:YES error:nil]; 

However, when I tried to use the category setCategory: AVAudioSessionCategoryPlayAndRecord. The route to the Bluetooth device stops working. I do not know why. Since, by right, the bluetooth option should only work for the Record or PlayAndRecord category ...

/ * valid only with AVAudioSessionCategoryRecord and AVAudioSessionCategoryPlayAndRecord * /

Addendum: Can I use bluetooth to output ONLY (the input still uses the default microphone from the phone)?

UPDATE

I changed the order by first calling setMode and then setCategory. It works for the first time when you start the application (call). When I tried to do the same thing again, currentRoute still gave me output = Bluetooth, but the actual output will return to the front speaker of the phone by default.

+7
ios objective-c iphone ios7 bluetooth
source share
2 answers

It has been a while since I posted this question, and I kind of forgot what exactly the problem is ... If I remember correctly this is due to another lib that kept rewriting the output route. somehow I fixed it and did as I want.

I contributed the code to the Jawbone AudioSessionManager lib. Hope this helps.

+2
source share

Can you remember how this was decided? I have the same problem.

0
source share

All Articles