It's easy you have to respond to the Remote Control Events. This also lets you control your app with the headset.
In lets say viewDidLoad call:
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];
And you have to respond to both
- (BOOL)canBecomeFirstResponder {
return YES;
}
And
- (void)remoteControlReceivedWithEvent:(UIEvent *)event {
switch (event.subtype) {
case UIEventSubtypeRemoteControlTogglePlayPause:
if (audio.rate == 0.0) {
[audio play];
} else {
[audio pause];
}
break;
case UIEventSubtypeRemoteControlPlay:
[audio play];
break;
case UIEventSubtypeRemoteControlPause:
[audio pause];
break;
default:
break;
}
}