I got the following code:
- (id)init {
if (self = [super init]) {
UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
AudioSessionS
Very good example here http://ruckt.info/playing-sound-through-iphone-speaker/ Solved my problem.
The method below - configureAVAudioSession - reroutes the audio to the main speakers in iOS 7.0. To do so, call it before playing the audio in this way: [self configureAVAudioSession]
.
- (void) configureAVAudioSession //To play through main iPhone Speakers
{
//get your app's audioSession singleton object
AVAudioSession* session = [AVAudioSession sharedInstance];
//error handling
BOOL success;
NSError* error;
//set the audioSession category.
//Needs to be Record or PlayAndRecord to use audioRouteOverride:
success = [session setCategory:AVAudioSessionCategoryPlayAndRecord error:&error];
if (!success)
{
NSLog(@"AVAudioSession error setting category:%@",error);
}
//set the audioSession override
success = [session overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:&error];
if (!success)
{
NSLog(@"AVAudioSession error overrideOutputAudioPort:%@",error);
}
//activate the audio session
success = [session setActive:YES error:&error];
if (!success)
{
NSLog(@"AVAudioSession error activating: %@",error);
}
else
{
NSLog(@"audioSession active");
}
}