MPMoviePlayerController fullscreen mode issue

人走茶凉 提交于 2019-12-04 14:14:44

问题


I have a problem with my code that plays a video file. Whenever I play the file in fullscreen mode the playback doesn't occupy all of my screen. Here is the relevant code:

     NSURL *url = [NSURL fileURLWithPath:@"Somefile.mov"];
     moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
    [moviePlayer setControlStyle:MPMovieControlStyleFullscreen];
    [moviePlayer setFullscreen:YES];
    moviePlayer.view.frame = self.switchView.frame;
    [self.switchView addSubview:moviePlayer.view];

    [[NSNotificationCenter defaultCenter] 
    addObserver:self
    selector:@selector(movieFinishedCallback:)                                                 
    name:MPMoviePlayerPlaybackDidFinishNotification
    object:moviePlayer];

    [[NSNotificationCenter defaultCenter] 
     addObserver:self
     selector:@selector(playbackStateDidChange:)                                                 
     name:MPMoviePlayerPlaybackStateDidChangeNotification
     object:moviePlayer];

    [moviePlayer prepareToPlay];
    [moviePlayer play];

Here is the output I get:


回答1:


Option A: Use the MPMovieViewController instead and display it modally using presentMoviePlayerViewControllerAnimated:.

Option B: Make sure your switchView (which you use for adding the moviePlayer's view to) actually occupies the entire screen.

Option C: Readjust the frame of the moviePlayer's view with negative vertical offsets until it fits - eg.: moviePlayer.view.frame = CGRectMake(0.0f, -20.0f, 320.0f, 480.0f);

Note: MPMoviePlayerController always displays a status bar when using the control style MPMovieControlStyleFullscreen, no matter how the rest of your app handles the status-bar.




回答2:


Change the controlstyle property of your player from the method below: -(void)applyUserSettingsToMoviePlayer

player.controlStyle = MPMovieControlStyleFullScreen causes the above problem,change it to MPMovieControlStyleEmbedded and see if that works.



来源:https://stackoverflow.com/questions/5689107/mpmovieplayercontroller-fullscreen-mode-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!