我使用MPMoviePlayerController来显示视频。问题是我不想全屏显示视频,我只想在小视图中显示它。
全屏幕正常工作但是当我添加此行(设置视频帧)时,它不再起作用。
_moviePlayer.view.frame = CGRectMake(250, 150, 500, 500);
这是我的代码:
ViewController.h
@property (strong, nonatomic) MPMoviePlayerController *moviePlayer;
ViewController.m
NSURL *url = [NSURL URLWithString:
@"http://www.ebookfrenzy.com/ios_book/movie/movie.mov"];
_moviePlayer = [[MPMoviePlayerController alloc]
initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:_moviePlayer];
_moviePlayer.controlStyle = MPMovieControlStyleDefault;
_moviePlayer.shouldAutoplay = YES;
[_moviePlayer setScalingMode:MPMovieScalingModeFill];
_moviePlayer.view.frame = CGRectMake(250, 150, 500, 500);
[self.view addSubview:_moviePlayer.view];
[_moviePlayer setFullscreen:NO animated:YES];
有什么想法吗?或者MPMoviePlayerController不是正确的对象? 谢谢!
答案 0 :(得分:0)
skipp the line [_moviePlayer setScalingMode:MPMovieScalingMofeFill]。此行不允许您在RECTMAKE中显示您的视频,因为这必须填满整个屏幕。