I am trying to get my app to respond to events like pausing with headphones, or with the controls in multitasking bar. In the view that loads the MPMoviePlayerController, I put in the viewDidLoad:
UPDATE: I figured out where the issue is, but am having problems with this:
I added this to the viewDidLoad method, but am not sure what needs to be put in the playbackStateChanged notification method, as playbackState is a read-only property. In my didReceiveRemoteEvents, I set to:
with playOrStop code as:
When I start playing, and send app to background, pull up multitasking bar and click pause, it pauses, but when I click play, nothing happens. Why is it not detecting the change in playbackState?
UPDATE: I figured out where the issue is, but am having problems with this:
Code:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackStateChanged:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:player];
Code:
case UIEventSubtypeRemoteControlTogglePlayPause:
[self playOrStop];
break;
Code:
if (player.playbackState == MPMoviePlaybackStatePlaying) {
[player pause];
}
if (player.playbackState == MPMoviePlaybackStatePaused) {
[player play];
}
Last edited: