How do I catch the MPMoviePlayer next button click event while in fullscreen mode on the iPad?

末鹿安然 提交于 2019-12-03 20:59:51

Here's another possibility I just stumbled across. The MPMoviePlayerController in full-screen mode may be sending Remote Control events. Catch these (iOS 4 only, by the way) by enabling remote control event messages in your view controller:

[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];

and then implement

[UIResponder remoteControlReceivedWithEvent:(UIEvent*)event];

and when the view goes away, unregister in viewWillDisappear:

[[UIApplication sharedApplication] endReceivingRemoteControlEvents];
[self resignFirstResponder];

I'm not certain that this will work, but it's worth a shot.

I haven't used MPMoviePlayerViewController, but here are some thoughts based on peeking at the documentation.

It looks like the MPMoviePlayerController has some notifications that might be relevant, though I don't see specific references to "next and previous buttons". Might they be Seek buttons?

Register for the notification with

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerPlaybackStateChanged:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil];

And add this function to your object:

-(void)moviePlayerPlaybackStateChanged:(NSNotification *)notification {
    MPMoviePlayerController *moviePlayer = notification.object;
    MPMoviePlaybackState playbackState = moviePlayer.playbackState;
    // ...
}

I suspect you'll find that you're getting MPMoviePlaybackStateSeekingForward and ...SeekingBackward updates for those buttons.

alones

Seaamsu Campbell is right :) Using his approach I got events of playback control events. See my question and answer.

How can I know users click fast forward and fast rewind buttons on the playback controls in iPhone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!