iOS的7蓝牙输出工作不适合AVAudioSessionCategoryPlayAndRecord [英] iOS 7 Bluetooth Output not working for AVAudioSessionCategoryPlayAndRecord
问题描述
在我的应用程序,如果iPhone连接到蓝牙耳机,播放声音与蓝牙。否则使用默认的扬声器。
In my app, if iPhone is connected to Bluetooth headset, play sound with Bluetooth. Else use default speaker.
下面是我的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];
然而,当我试图用类setCategory:AVAudioSessionCategoryPlayAndRecord。路线蓝牙设备停止工作..我不知道为什么。因为通过右键,蓝牙选项应该只用于录音或PlayAndRecord类工作...
However, when I tried to use category setCategory:AVAudioSessionCategoryPlayAndRecord. Route to bluetooth device stopped working.. I don't know why. Because by right, the bluetooth option should only work for Record or PlayAndRecord category...
/ *只有AVAudioSessionCategoryRecord有效AVAudioSessionCategoryPlayAndRecord * /
/* only valid with AVAudioSessionCategoryRecord and AVAudioSessionCategoryPlayAndRecord */
增加:?我能有蓝牙只能输出(输入仍在使用默认的麦克风从电话)
Addition: Can I have bluetooth for output ONLY (input still use default Mic from phone)?
更新
我通过调用setMode第一,其次是setCategory改变的顺序。它适用于运行的应用程序(通话中)的第一次。当我试图再次做同样的动作,currentRoute还是给了我输出=蓝牙但实际产量恢复到默认的电话前置扬声器。
I changed the order by calling setMode first, followed by setCategory. It works for the first time running the application (a call). When I tried to do the same action again, currentRoute still gave me output = Bluetooth but the actual output returns to default phone front speaker.
推荐答案
这已经有一段时间,因为我张贴这个问题,我有点忘了究竟是什么问题...如果我记得正确的是因另一LIB下不停改写输出路线。不知何故,我固定它,并使其工作,我想要的方式。
It has been a while since I post this question and I kind forgot what exactly the problem is... If I remembered correctly it's due to another lib that kept rewriting the output route. somehow I fixed it and made it work the way I want.
我贡献了code到Jawbone的 AudioSessionManager 库。希望有所帮助。
I contributed the code to Jawbone's AudioSessionManager lib. Hope that helps.
这篇关于iOS的7蓝牙输出工作不适合AVAudioSessionCategoryPlayAndRecord的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!