I am writing code that uses [MPMusicPlayerController applicationMusicPlayer] to play music.
This works successfully and displays information about the currently playing track on the Control Center screen.
Unfortunately, I cannot get the remote control buttons to work with the Control Center screen or with the headset.
I turned on the background sound made by the application, will play in the background, and turned on some MPRemoteCommandCenter commands using code similar to the one shown below. The code below is based on what I saw in the documentation and in this SO question
MPRemoteCommandCenter *rcc = [MPRemoteCommandCenter sharedCommandCenter]; MPRemoteCommand *playCommand = rcc.playCommand; playCommand.enabled = YES; [playCommand addTargetWithHandler:^MPRemoteCommandHandlerStatus(MPRemoteCommandEvent *event) { MPMusicPlayerController *musicPlayer = [MPMusicPlayerController applicationMusicPlayer]; [musicPlayer play]; NSLog(@"Play button pressed"); return MPRemoteCommandHandlerStatusSuccess; }];
Using the code above, it will cause the Control Center buttons to do nothing or start playing the music application.
I am sure that there is something simple that I am missing, but I do not see it. I tried to call [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; but actually it should not be used with MPRemoteCommandCenter, as far as I can tell.
I work with Xcode 6.2 and iOS 8.2.
I have tried everything I can think of here. How do I get MPRemoteCommandCenter to work as I expect?
source share