我有一个 MPMoviePlayerController,它使用默认控件在一个小框架内播放视频。如果我按下媒体播放器控件上的“全屏”按钮,一切正常 - 视频仍在播放。视频完成后,我想关闭全屏视图并返回非全屏视图控制器。
我的应用程序仅是横向的。我已经测试了“setFullscreen”属性以在调用 MPMoviePlayerPlaybackDidFinishNotification 时切换回来——这有效。但是出现了从纵向到横向的视图旋转,这是错误的。我只需要风景到风景。
任何想法为什么会发生这种情况?
self.moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
[self.moviePlayerController prepareToPlay];
[self.moviePlayerController setShouldAutoplay:YES];
self.moviePlayerController.movieSourceType = MPMovieSourceTypeFile;
self.moviePlayerController.fullscreen = NO;
self.moviePlayerController.scalingMode = MPMovieScalingModeAspectFit;
self.moviePlayerController.controlStyle = MPMovieControlStyleEmbedded;
[self.moviePlayerController.view setFrame: someMovieFrame];
[tempImageScrollView addSubview:self.moviePlayerController.view];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlaybackCompletePSV:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:self.moviePlayerController];
[self.moviePlayerController play];
- (void) moviePlaybackCompletePSV:(NSNotification*) notification {
MPMoviePlayerController *mymoviePlayerController = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:mymoviePlayerController];
NSLog(@"PSV moviePlaybackComplete!");
// movie fadeout transition ====================
self.moviePlayerController.view.alpha = 1;
[UIView animateWithDuration:0.3f delay:0.0 options:UIViewAnimationCurveEaseOut
animations:^{
self.moviePlayerController.view.alpha = 0;
if ([self.moviePlayerController isFullscreen]) {
NSLog(@"PSV fullscreen movieplayer deleted");
[self.moviePlayerController setFullscreen:NO animated:NO];
}
}
completion:^(BOOL finished) {
[mymoviePlayerController stop];
[mymoviePlayerController.view removeFromSuperview];
[self.moviePlayerController.view removeFromSuperview];
self.moviePlayerController = nil;
}];
}