I need to handle AVPlayer interruptions like incoming calls and headphones unplugging.
So i'm trying to use the following code:
ViewController.h
@interface ViewController : UIViewController <UIWebViewDelegate, AVAudioSessionDelegate>
ViewController.m
- (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
{
}
beginInterruption and endInterruptionWithFlags: were called when the incoming call was received, but not when headphones were unplugged.
I can use callback instead of delegate but i don't want to duplicate the code.