【发布时间】:2014-06-20 13:30:26
【问题描述】:
我有一个 MPMoviePlayerController 实例,当我第一次将 iPhone 旋转到横向模式时,它可以在纵向模式和全屏模式下正确显示 HLS 视频流。当我从全屏返回时会出现问题:我的 MPMoviePlayerController 的 scalingMode 属性仍设置为 MPMovieScalingModeAspectFill,但视频显示为设置为 MPMovieScalingModeAspectFit。
在将其视图添加为我的视图 (self.movieView) 的子视图 (self.moviePlayer.view) 之前,我将它的 scalingMode 设置为 MPMovieScalingModeAspectFill 并且一切正常,直到我退出全屏。
- (void) play
{
self.moviePlayer = [[MPMoviePlayerController alloc] init];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidStart:) name:MPMoviePlayerLoadStateDidChangeNotification object:self.moviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:self.moviePlayer];
self.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
self.moviePlayer.contentURL = videoURL;
self.moviePlayer.controlStyle = MPMovieControlStyleNone;
self.moviePlayer.shouldAutoplay = YES;
self.moviePlayer.scalingMode = MPMovieScalingModeAspectFill;
NSLog(@"%ld", (long) self.moviePlayer.scalingMode);
self.moviePlayer.view.frame = CGRectMake(0, 0, 320, 180);
[self.movieView addSubview:self.moviePlayer.view];
[self.moviePlayer setFullscreen:NO animated:NO];
}
当我从全屏返回时,它被设置为默认值 (MPMovieScalingModeAspectFit),即使我在收到 MPMoviePlayerScalingModeDidChangeNotification 时明确尝试,我也无法将其更改回 MPMovieScalingModeAspectFill。
- (void)movieScalingModeDidChange:(NSNotification *)notification
{
self.moviePlayer.scalingMode = MPMovieScalingModeAspectFill;
NSLog(@"%ld", (long) self.moviePlayer.scalingMode);
}
奇怪的是,这个 NSLog 给了我:
-[CameraViewController play]:2
根据文档,这是 MPMovieScalinModeAspectFill 的枚举,但视频不是此方面模式。
typedef enum {
MPMovieScalingModeNone,
MPMovieScalingModeAspectFit,
MPMovieScalingModeAspectFill,
MPMovieScalingModeFill
} MPMovieScalingMode;
有没有人遇到过同样的问题?提前致谢!
【问题讨论】:
标签: ios objective-c mpmovieplayercontroller fullscreen scaling