I need to display iPod (transport) controls and receive events to control the MPMoviePlayerController player in the background. I've implemented the following:
- (void)remoteControlReceivedWithEvent:(UIEvent *)theEvent {
NSLog("Not getting here");
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];
}
- (BOOL)canBecomeFirstResponder {
return YES;
}
I've also activated the audio session and
if (![session setCategory:AVAudioSessionCategoryPlayback
withOptions:AVAudioSessionCategoryOptionMixWithOthers
error:&setCategoryError]) {
// handle error
}
Finally, my info.plist is set up to enable the application to run in the background.
If I am playing media through the movie player and I background the app, I don't even get a display of the controls. I've tried implementing this in both a singleton and a view controller.
What's more mysterious is that if I am playing a song through the MPMusicPlayerController player when I background the app, I do see controls and the controls actually work. But no events from those controls are received by my method remoteControlReceivedWithEvent.
What do I need to do to see the controls and to receive events from the controls?