Im just trying to play a simple audio file. Here is the scenario, the app is started and i "prepare to play" the audio on viewdidLoad. When i go into the BACKGROUND i need to play music for a brief moment but it wont play in ambient category but AVAudioSessionCategoryPlayback
works fine. I need it to be ambient category so the user can mute the sound if they want.
-(void) startRing
{
{
OSStatus error;
UInt32 value;
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryAmbient error: nil];
value = kAudioSessionOverrideAudioRoute_Speaker;
error = AudioSessionSetProperty(kAudioSessionProperty_OverrideAudioRoute, sizeof(value), &value);
if (error)
NSLog(@"couldn't set kAudioSessionOverrideAudioRoute_Speaker!");
[ringTonePlayer play];
NSLog(@"ringing %s",[ringTonePlayer isPlaying]?"true":"false");//this always shows false when im in the background
self->ringing = true;
}
}
in my info plist im putting that this app uses audio in the background as a background mode. the issue is i need to START the audio while in the background but the system wont let me in ambient mode.