我正在使用 MPMoviePlayerController
,我需要检测用户按下“下一个/上一个”按钮。我已尝试了多种方法,但都没有奏效。
以下是我尝试过的内容:
- 遥控器事件
-(void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];
}
-(void) viewWillDisappear:(BOOL)animated
{
[[UIApplication sharedApplication] endReceivingRemoteControlEvents];
[self resignFirstResponder];
[super viewWillDisappear:animated];
}
-(BOOL)canBecomeFirstResponder
{
return YES;
}
-(void)remoteControlReceivedWithEvent:(UIEvent *)receivedEvent
{
// stuff
}
问题是remoteControlReceivedWithEvent
方法从未被调用。我读过,这在iOS版本高于6的情况下不起作用 - 我正在使用iOS 7。
- 通知
我尝试使用MPMoviePlayerPlaybackStateDidChangeNotification
并检查MPMoviePlaybackStateSeekingForward
或MPMoviePlaybackStateSeekingBackward
- 不幸的是,这些播放状态仅在拖动播放栏时设置,而不是按Next/Prev按钮时设置。
有什么想法吗?