iPhone MediaPlayer - Fullscreen?
I've gone through a bunch of other examples, but I cannot get a video to load full screen in a viewController.
I'm able to get it to load... but not launch in full screen.
The code is below. Thanks!
-(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) movieFinishe开发者_JAVA百科dCallback:(NSNotification*) aNotification {
MPMoviePlayerController *player = [aNotification object];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
[player autorelease];
}
Edit: Full screen fixed... I just had to add: moviePlayerController.controlStyle = MPMovieControlStyleFullscreen;
Now it adds an odd image to my status bar.. see attached photo.
I don't know what you mean by fullscreen
means, but I normally see this line
[moviePlayerController.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
written with bounds
as an argument like this
[moviePlayerController.view setFrame:self.bounds];
or
[moviePlayerController.view setFrame:self.view.bounds];
depending on what type of object self
is.
精彩评论