我如何在iphone上捕获MPMoviePlayer进度条跟踪事件

时间:2011-02-22 09:11:28

标签: iphone progress-bar mpmovieplayercontroller

在我的应用程序中,我使用MPMoviePlayerController播放视频。我想在用户试图跳过电影时跟踪事件(跟踪进度条)。

在此之前,只是澄清了我的疑问,当用户试图跳过视频时,是否有可能获得该事件(跟踪进度条)。

谢谢你:)

2 个答案:

答案 0 :(得分:2)

为MPMoviePlayerController定义了许多通知

//缩放模式更改时发布。

MP_EXTERN NSString *const MPMoviePlayerScalingModeDidChangeNotification;

// Posted when movie playback ends or a user exits playback.
MP_EXTERN NSString *const MPMoviePlayerPlaybackDidFinishNotification;

MP_EXTERN NSString *const MPMoviePlayerPlaybackDidFinishReasonUserInfoKey NS_AVAILABLE_IPHONE(3_2); // NSNumber (MPMovieFinishReason)

// Posted when the playback state changes, either programatically or by the user.
MP_EXTERN NSString *const MPMoviePlayerPlaybackStateDidChangeNotification NS_AVAILABLE_IPHONE(3_2);

// Posted when the network load state changes.
MP_EXTERN NSString *const MPMoviePlayerLoadStateDidChangeNotification NS_AVAILABLE_IPHONE(3_2);

// Posted when the currently playing movie changes.
MP_EXTERN NSString *const MPMoviePlayerNowPlayingMovieDidChangeNotification NS_AVAILABLE_IPHONE(3_2);

// Posted when the movie player enters or exits fullscreen mode.
MP_EXTERN NSString *const MPMoviePlayerWillEnterFullscreenNotification NS_AVAILABLE_IPHONE(3_2);
MP_EXTERN NSString *const MPMoviePlayerDidEnterFullscreenNotification NS_AVAILABLE_IPHONE(3_2);
MP_EXTERN NSString *const MPMoviePlayerWillExitFullscreenNotification NS_AVAILABLE_IPHONE(3_2);
MP_EXTERN NSString *const MPMoviePlayerDidExitFullscreenNotification NS_AVAILABLE_IPHONE(3_2);
MP_EXTERN NSString *const MPMoviePlayerFullscreenAnimationDurationUserInfoKey NS_AVAILABLE_IPHONE(3_2); // NSNumber of double (NSTimeInterval)
MP_EXTERN NSString *const MPMoviePlayerFullscreenAnimationCurveUserInfoKey NS_AVAILABLE_IPHONE(3_2);     // NSNumber of NSUInteger (UIViewAnimationCurve)
你需要哪一个?

答案 1 :(得分:-1)

我已经尝试并得到了这个问题的答案(进度条跟踪通知),

<强> CODE:

-(void) moviePlayerPlaybackStateDidChange:(NSNotification*)notification {

NSLog(@"moviePlayerPlaybackStateDidChange");
MPMoviePlayerController *moviePlayer = notification.object;
MPMoviePlaybackState playbackState = moviePlayer.playbackState;
if(playbackState == MPMoviePlaybackStateStopped)
{
    NSLog(@"MPMoviePlaybackStateStopped");
} 
if(playbackState == MPMoviePlaybackStatePlaying) 
{
    NSLog(@"MPMoviePlaybackStatePlaying");
} 
if(playbackState == MPMoviePlaybackStatePaused)
{
    NSLog(@"MPMoviePlaybackStatePaused");
} 
if(playbackState == MPMoviePlaybackStateInterrupted) 
{
    NSLog(@"MPMoviePlaybackStateInterrupted");
} 
if(playbackState == MPMoviePlaybackStateSeekingForward)
{
    NSLog(@"MPMoviePlaybackStateSeekingForward");
} 
if(playbackState == MPMoviePlaybackStateSeekingBackward)
{
    NSLog(@"MPMoviePlaybackStateSeekingBackward********");
}

}