IOS how to stream audio to bluetooth speaker

I want to stream my voice from iPhone 4 (iOS 7) to Bluetooth Speaker Device (this one) with lowest latency / latency possible.

I was able to almost instantly capture my voice and stream it to my speaker via the audio jack, but when I connect my Iphone using my Bluetooth speaker, it doesn't work. I hear nothing.

And when I open Youtube in my iPhone, the audio is correctly transmitted to the bluetooth speaker device. So the problem is not with the Bluetooth Speaker Device, but with my code.

Do you have any suggestions or advice?

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];

      

+3


source to share





All Articles