【发布时间】:2015-05-12 14:40:56
【问题描述】:
我有MPMoviePlayerController,我只想检测下一个/上一个按钮以便相应地播放播放列表,我添加了通知,但它总是返回MPMoviePlaybackStateStopped 状态而不是MPMoviePlaybackStateSeekingForward 或MPMoviePlaybackStateSeekingBackward。
代码如下:
[[NSNotificationCenter defaultCenter] addObserver:self // the object listening / "observing" to the notification
selector:@selector(stateChanged:) // method to call when the notification was pushed
name:MPMoviePlayerPlaybackStateDidChangeNotification // notification the observer should listen to
object:nil];
并在回调函数中:
-(void)stateChanged:(NSNotification *)notification{
MPMoviePlaybackState state = self.moviePlayerViewController.moviePlayer.playbackState;
switch (state) {
case MPMoviePlaybackStateStopped:
NSLog(@"Stopped");
break;
case MPMoviePlaybackStateInterrupted:
NSLog(@"Interrupted");
break;
case MPMoviePlaybackStateSeekingForward:
NSLog(@"forward");
currentIndex++;
ForcePlay = true;
[self PlayVideo:currentIndex];
break;
case MPMoviePlaybackStateSeekingBackward:
NSLog(@"backward");
currentIndex--;
ForcePlay = true;
[self PlayVideo:currentIndex];
break;
case MPMoviePlaybackStatePaused:
NSLog(@"paused");
break;
case MPMoviePlaybackStatePlaying:
NSLog(@"playing");
break;
}
}
【问题讨论】:
标签: ios mpmovieplayercontroller nsnotifications