我希望用我的iPhone 4(iOS 7)将我的声音传输到具有最低延迟/延迟的Bluetooth Speaker Device (this one) .
我设法以几乎没有延迟的方式捕获我的声音并通过音频插孔连接器将其广播到我的扬声器但是当我将我的Iphone与我的蓝牙扬声器设备配对时它不起作用 . 我什么都没听到 .
当我在iPhone中打开Youtube时,声音会正确传输到蓝牙扬声器设备 . 所以问题不在于蓝牙扬声器设备,而在于我的代码 .
你有什么建议或意见吗?
这是我在委托类(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];