title: AVPlayer interruptions handling
body: <p>I need to handle AVPlayer interruptions like incoming calls and headphones unplugging.</p>
  
  <p>So i'm trying to use the following code:</p>
  
  <p>ViewController.h</p>
  
  <pre><code>@interface ViewController : UIViewController &lt;UIWebViewDelegate, AVAudioSessionDelegate&gt;
  </code></pre>
  
  <p>ViewController.m</p>
  
  <pre><code>- (void)viewDidLoad
  {
      [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
      [[AVAudioSession sharedInstance] setActive:YES error:nil];
      [[AVAudioSession sharedInstance] setDelegate:self];
  }
  
  - (void)beginInterruption
  {
  
  }
  
  - (void)endInterruption
  {
  
  }
  
  - (void)endInterruptionWithFlags:(NSUInteger)flags
  {
  
  }
  </code></pre>
  
  <p>beginInterruption and endInterruptionWithFlags: were called when the incoming call was received, but not when headphones were unplugged.</p>
  
  <p>I can use callback instead of delegate but i don't want to duplicate the code.</p>