The UIEvent
delegate way of handling remote control events is no longer recommended for audio/video event handling. Instead, MPRemoteCommandCenter
provides a selector-based interface to enable and disable buttons and remote control events, as well as the actions to handle those events.
In the case where content should not be paused or resumed, you will have to explicitly set enabled
property for each command to NO
AND provide an action, even if it is just a dummy selector that does nothing, in order to disable the buttons in the Control Center properly:
MPRemoteCommandCenter *commandCenter = [MPRemoteCommandCenter sharedCommandCenter];
commandCenter.playCommand.enabled = NO;
[commandCenter.playCommand addTarget:self action:@selector(playAudio)];
commandCenter.pauseCommand.enabled = NO;
[commandCenter.pauseCommand addTarget:self action:@selector(pauseAudio)];
I elaborate on this further with an example from working with AVPlayer here.