I have an app that plays recorded audio as well as repeating sounds. The sounds play correctly through the onboard iPad speaker, and if I plug in a cord from the earphone jack to my stereo audio-in, it also plays well. When I pair my iPad to my bluetooth stereo input, all the sounds from my other apps (written for iPhone, running on my iPad) work fine, as does all other sound from my device.
The problem is my app written for iPad is NOT playing over the bluetooth path, but instead plays from the built-in speakers.
In my app delegate in the didFinishLaunchingWithOptions(…) method, I have placed the following:
NSError *error = nil;
[[AVAudioSession sharedInstance] setMode:AVAudioSessionModeDefault error:&error];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:&error];
[[AVAudioSession sharedInstance] setActive:YES error:&error];
This code is being called and there are no errors being returned.
In my controller code, I have recorded samples that I play using AVAudioPlayer as follows:
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:recordURL error:&error];
audioPlayer.numberOfLoops = 0;
[audioPlayer setDelegate:self];
[audioPlayer play];
In other areas, I have drones that are playing short .01 second sounds repeated in a threaded controlled loop and I do this using OpenAL :
alSourcePlay(sourceID);
This is the same code as I have in my other apps written for iPhone that works as desired.
I realize that there are other threads regarding bluetooth input, but I am having a specific issue with bluetooth output of audio sounds from my iPad app.