title: How to resume AVAudioPlayer after interrupted in background
body: <p>I am playing music using AVAudioPlayer in background. The problem is: if there is a incoming calling interrupts the player, it will never resume unless switch to foreground and do it manually.</p>
  
  <p>The code is simple, to play it in background:</p>
  
  <pre><code>[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayAndRecord  error: nil];
  [[AVAudioSession sharedInstance]  setActive: YES error: nil];
  
  url = [[NSURL alloc] initFileURLWithPath:...];
  
  audio_player = [[AVAudioPlayer alloc] initWithContentsOfURL: url error:NULL];
  audio_player.delegate = self;
  bool ret = [audio_player play];
  </code></pre>
  
  <p>delegate to handle interruptions:</p>
  
  <pre><code>-(void)audioPlayerBeginInterruption:(AVAudioPlayer *)player
  {
      //tried this, not working [[AVAudioSession sharedInstance]  setActive: NO error: nil]; 
      NSLog(@"-- interrupted --");
  }
  
  
  //----------- THIS PART NOT WORKING WHEN RUNNING IN BACKGROUND ----------
  - (void)audioPlayerEndInterruption:(AVAudioPlayer *)player
  {
      NSLog(@"resume!");
      //--- tried, not working: [[AVAudioSession sharedInstance] setCategory:             AVAudioSessionCategoryPlayAndRecord  error: nil];
      //--- tried, not working: [[AVAudioSession sharedInstance]  setActive: YES error: nil];
      //--- tried, not working: [audio_player prepareToPlay];
      [audio_player play];
  }
  </code></pre>
  
  <p>Can any one help me?</p>