I registered some handler for MPRemoteCommandCenter
[[[MPRemoteCommandCenter sharedCommandCenter] playCommand] addTarget:self action:@selector(playFromRemote:)];
[[[MPRemoteCommandCenter sharedCommandCenter] togglePlayPauseCommand] addTarget:self action:@selector(playFromRemote:)];
[[[MPRemoteCommandCenter sharedCommandCenter] stopCommand] addTarget:self action:@selector(stopFromRemote:)];
[[[MPRemoteCommandCenter sharedCommandCenter] pauseCommand] addTarget:self action:@selector(stopFromRemote:)];
Commands do nothing more than call an internal handler and return MPRemoteCommandHandlerStatusSuccess
- (MPRemoteCommandHandlerStatus)playFromRemote:(MPRemoteCommandEvent *)event {
NSLog(@"Got remote command.");
return MPRemoteCommandHandlerStatusSuccess;
}
The problem is that I get the "pauseCommand" when the user presses play/pause on the remote (and I stop the audio stream). Pressing again the remote play button don't send anything to the program.
In other words, I get only the "pause" command and not the play (or toggle playPause one), there is something I forgot to set in other places or it's a bug?
Similar code (ported directly from iOS) using the deprecated
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
have the same problem, I only get "pause", no "play"...
Any hint or suggestion is appreciated...