我已经浏览了一些其他示例,但我无法在viewController中获取全屏加载视频。
我可以加载它......但不能全屏启动。
代码如下。谢谢!
-(void)viewWillAppear:(BOOL)animated {
NSString *filepath = [[NSBundle mainBundle] pathForResource:@"Sample" ofType:@"m4v"];
NSURL *fileURL = [NSURL fileURLWithPath:filepath];
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlaybackComplete:)
name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayerController];
[moviePlayerController.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
[self.view addSubview:moviePlayerController.view];
moviePlayerController.fullscreen = YES;
[moviePlayerController play];
}
- (void) movieFinishedCallback:(NSNotification*) aNotification {
MPMoviePlayerController *player = [aNotification object];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
[player autorelease];
}
编辑:全屏固定...我只需添加:moviePlayerController.controlStyle = MPMovieControlStyleFullscreen;
现在它在我的状态栏中添加了一个奇怪的图像..参见附图。
答案 0 :(得分:0)
我不知道fullscreen
的含义是什么意思,但我通常会看到这一行
[moviePlayerController.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
用bounds
作为参数编写,如下所示
[moviePlayerController.view setFrame:self.bounds];
或
[moviePlayerController.view setFrame:self.view.bounds];
取决于对象self
的类型。