Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

newtoiphonesdk

macrumors 6502a
Original poster
Jul 30, 2010
567
2
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:
Code:
 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackStateChanged:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:player];
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:
Code:
case UIEventSubtypeRemoteControlTogglePlayPause:
                
                [self playOrStop];
                
                break;
with playOrStop code as:
Code:
if (player.playbackState == MPMoviePlaybackStatePlaying) {
        [player pause];
    }
    if (player.playbackState == MPMoviePlaybackStatePaused) {
        [player play];
    }
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?
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.