1

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.

Andrew Tetlaw
  • 2,669
  • 22
  • 27
j2emanue
  • 60,549
  • 65
  • 286
  • 456
  • link below seems to show that ambient category in the background is not possible .... but i need the mute button to work ...this is rather ridiculous of apple http://stackoverflow.com/questions/8763942/avaudioplayer-using-ambientsound-session-is-not-playing-when-app-is-in-backgro – j2emanue Aug 27 '12 at 01:18

0 Answers0