开发者

Trouble presenting MPMoviePlayerViewController, or MoviePlayerController in fullscreen

开发者 https://www.devze.com 2023-04-11 05:02 出处:网络
I\'m trying to create a movie to play when my app starts up.The first view Controller is a UITabBarController.In the code for the view controller for the first tab, is where I put my movie.This dummy

I'm trying to create a movie to play when my app starts up. The first view Controller is a UITabBarController. In the code for the view controller for the first tab, is where I put my movie. This dummy code works (setting the frame to be smaller than the full screen and just showing the video):

- (void)PlayOpeningMovie {
    NSString *filepath   =   [[NSBundle mainBundle] pathForResource:@"test" ofType:@"m4v"];  
    NSURL    *fileURL    =   [NSURL fileURLWithPath:filepath];  
    MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];  
//    MPMoviePlayerViewController *moviePlayerController = [[MPMoviePlayerViewController alloc] initWithContentURL:fileURL];
    [moviePlayerController.view setFrame:CGRectMake(120, 120, 300, 200)];

    [[NSNotificationCenter defaultCenter] addObserver:self  
                                             selector:@selector(moviePlaybackComplete:)  
                                                 name:MPMoviePlayerPlaybackDidFinishNotification  
                                               object:moviePlayerController];  
    [self.vi开发者_开发百科ew addSubview:moviePlayerController.view];  
//    [moviePlayerController setFullscreen:YES];
//    [self presentMoviePlayerViewControllerAnimated:moviePlayerController];

    [moviePlayerController play];  
//    [[moviePlayerController moviePlayer] play];
}

However, if I switch it around, comment out the setFrame method, and use the fullscreen property, I do not see the movie.

I was also playing around with creating a MPMovieplayerViewController and presenting that modally with the method for the MPMoviePlayerViewControllers, but it never gets presented and I can't figure out why. I tried creating a dummy viewController with a yellow background as well, and presenting that modally and that does not work either.

I have tried adding a dummy UIView to the screen, and that works.

So for some reason, I can get small UIViews/MPMoviePlayers to show with addSubview. I cannot get the presentModal__ to work. I cannot get fullscreen mode to work for the MoviePlayerController. I'm really stumped as to why I cannot present modally from this view. Thanks.


[moviePlayerController setControlStyle:MPMovieControlStyleFullscreen];

[moviePlayerController setFullscreen:YES];

Just add this two lines to present it in full screen.

0

精彩评论

暂无评论...
验证码 换一张
取 消