【发布时间】:2014-08-12 08:12:02
【问题描述】:
我在 iOS 7 上为我的应用程序使用蓝牙时遇到了问题。 更准确地说,我想连接的蓝牙接收器是:http://www.amazon.co.uk/Sony-Bluetooth-Receiver-Enhancement-Smartphone-Black/dp/B00G9YK7LS
当然,在我开始测试之前,iPhone 已与设备配对。
我的应用应该只使用 EZAudio 框架进行音频传递(从麦克风到扬声器)。使用 iPhone 耳机可以正常工作,但不能使用蓝牙。
这是我在委托类(didFinishLaunchingWithOptions 函数)中用于初始化音频会话的代码:
// 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];
然后我使用 EZAudio 框架将音频发送到音频设备:
/**
Start the output
*/
[EZOutput sharedOutput].outputDataSource = self;
[[EZOutput sharedOutput] startPlayback];
请问有人知道这个问题吗?我错过了什么吗?
感谢您的帮助!
【问题讨论】:
-
没有想法?没有人面临同样的问题?
标签: ios iphone audio ios7 bluetooth