我添加了这段代码:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loadMoviePlayerStateChanged:)
name:MPMoviePlayerLoadStateDidChangeNotification
object:self.mp];
它将我的 MPMoviePlayer 的每个状态更改触发到此函数中:
- (void) loadMoviePlayerStateChanged:(NSNotification*)notification
{
MPMoviePlayerController *Player = notification.object;
MPMoviePlaybackState playbackState = Player.playbackState;
if (playbackState == MPMoviePlaybackStateSeekingForward)
{
NSLog(@"Forward");
}
else if (playbackState == MPMoviePlaybackStateSeekingBackward)
{
NSLog(@"Backward");
}
}
它进入这个功能...
但问题在于 MPMoviePlaybackState
当我启动播放器时,playerState 为 1,而所有其他更改为 0。 - 那怎么可能?
编辑:
每次也执行此操作会得到 nil:
NSNumber *reason = [notification.userInfo objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey];
if ([reason intValue] == MPMoviePlaybackStateSeekingForward) {
// done button clicked!
}