IOS如何确定视频剪辑何时完成播放

IOS如何确定视频剪辑何时完成播放,ios,objective-c,iphone,xcode,video,Ios,Objective C,Iphone,Xcode,Video,在我的应用程序中,我需要播放一部来自vimeo的电影,这很好,但我的孔应用程序仅用于肖像。我想在特定的viewController中播放电影,并强制该控制器能够旋转到纵向或横向 当有人单击电影的缩略图时,我会转到VideoViewController,我需要知道如何确定此电影剪辑何时完成,以便在视频完成后直接将其重新分段 代码 在MPMoviePlayerController中,有可供您使用的通知列表。您需要的是MPMoviePlayerPlaybackDidFinishNotification

在我的应用程序中,我需要播放一部来自vimeo的电影,这很好,但我的孔应用程序仅用于肖像。我想在特定的viewController中播放电影,并强制该控制器能够旋转到纵向或横向

当有人单击电影的缩略图时,我会转到VideoViewController,我需要知道如何确定此电影剪辑何时完成,以便在视频完成后直接将其重新分段

代码


在MPMoviePlayerController中,有可供您使用的通知列表。您需要的是
MPMoviePlayerPlaybackDidFinishNotification

Posted when a movie has finished playing. The userInfo dictionary of this notification contains the MPMoviePlayerPlaybackDidFinishReasonUserInfoKey key, which indicates the reason that playback finished. This notification is also sent when playback fails because of an error.

您需要在viewDidLoad上添加一个观察者,以便在视频停止播放时,让它执行您的方法

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:playerView];
这是当视频停止播放时的接收器方法

- (void)moviePlayerDidFinish:(NSNotification *)notification
{
    //Do your stuff
}
- (void)moviePlayerDidFinish:(NSNotification *)notification
{
    //Do your stuff
}