我创建了一个AVPlayerViewController和一个附加AVPlayer在viewDidAppear一个自定义的方法UIViewController.但是,当我按下"完成"按钮时,我的自定义视图控制器会自动关闭.
我想拦截这个动作,以便使用我自己的放松塞格,但我不知道该怎么做.我找到了MPMoviePlayerViewController但不是的例子AVPlayerViewController.
我找到的代码MPMoviePlayerViewController如下:
- (void)playVideo:(NSString *)aVideoUrl {
// Initialize the movie player view controller with a video URL string
MPMoviePlayerViewController *playerVC = [[[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:aVideoUrl]] autorelease];
// Remove the movie player view controller from the "playback did finish" notification observers
[[NSNotificationCenter defaultCenter] removeObserver:playerVC
name:MPMoviePlayerPlaybackDidFinishNotification
object:playerVC.moviePlayer];
// Register this class as an observer instead
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:playerVC.moviePlayer];
// Set the modal transition style …Run Code Online (Sandbox Code Playgroud)