Search code examples
xcodevideoios5media-playermedia

NSMediaplayer status bar bug?


I'm using NSMediaPlayer to play my video. I'm hiding the status bar on the top with info plist file. After I play the movie the status bar comes up (I guess this is a bug with media player. I've tried hiding the status bar after the media finished with this code:

-(void)movieFinished


{
[[NSNotificationCenter defaultCenter]removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:[player moviePlayer]];
[player release];

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];

[[UIApplication sharedApplication] setStatusBarHidden:YES]; //this one
}

Now the problem is that in my view there is a scrollview and it has loads of UIImages and scrollviews inside. There is a space right where the status bar should be and the scrollviews and subviews are moved down a little bit.

Is there a solution to this? A fix to NSMediaPlayer maybe? I've searched the net but maybe I'm not entering the right words or nobody's got an issue with this?


Solution

  • Nevermind I've found the answer. If you use:

    [player.moviePlayer setControlStyle:MPMovieControlStyleFullscreen];
    

    The status bar appears no matter what you do.

    So after the movie finished you call a method with nsnotifications, in the movieFinished method you use this code to fix this issue:

    [[self view] setFrame:CGRectMake(0, -20, 1024, 768)]; // this code removes the empty space from the status bar
    
    [[UIApplication sharedApplication] setStatusBarHidden:YES]; //this code removes the status bar
    

    hope this helps someone