MPMoviePlayerController Exiting Fullscreen Pushes View Behind Status Bar

Discussion in 'iOS Programming' started by newtoiphonesdk, Mar 19, 2012.

  1. newtoiphonesdk macrumors 6502a

    Joined:
    Jul 30, 2010
    #1
    If I wait for the status bar and time bar to disappear after playing a movie, and rotate to landscape, and back to portrait, then click done, the original view shifts up to slightly behind the status bar (see picture below). Here is my code for playing the video:
    Code:
    - (IBAction)play {
    		NSBundle *bundle = [NSBundle mainBundle];
    		NSString *moviePath = [bundle pathForResource:@"welcome" ofType:@"mp4"];
    		NSURL  *movieURL = [[NSURL fileURLWithPath:moviePath] retain];
    		self.player =
            
            [[MPMoviePlayerController alloc] initWithContentURL: movieURL];
            
            [player prepareToPlay];
           
            player.allowsAirPlay = YES;
            player.scalingMode = MPMovieScalingModeAspectFit;
    
            self.player.view.frame = self.view.frame;
    
            [self.view addSubview: player.view];
            [self.player setFullscreen:YES animated:YES];
    
            // ...
            
            [[NSNotificationCenter defaultCenter] 
             addObserver:self
             selector:@selector(movieFinishedCallback:)
             name:MPMoviePlayerPlaybackDidFinishNotification
             object:player];
            
                    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(exitedFullscreen:) name:MPMoviePlayerDidExitFullscreenNotification object:player];
    
           
            [[NSNotificationCenter defaultCenter] addObserver:self
                                                     selector:@selector(moviePlayerWillExitFullscreen:)
                                                         name:MPMoviePlayerWillExitFullscreenNotification
                                                       object:player];
    
            
            [player play];
    	
    	
    }
    	
    - (void) movieFinishedCallback:(NSNotification*) aNotification {    
        NSLog(@"MovieDone");
        
        [player.view removeFromSuperview];   
        [[NSNotificationCenter defaultCenter]
         removeObserver:self
         name:MPMoviePlayerPlaybackDidFinishNotification
         object:player];
       }
    
    - (void) exitedFullscreen:(NSNotification*) aNotification {   
            NSLog(@"MovieDone");
        [player.view removeFromSuperview];   
        [[NSNotificationCenter defaultCenter]
         removeObserver:self
         name:MPMoviePlayerDidExitFullscreenNotification
         object:player];
        }
    - (void)moviePlayerWillExitFullscreen:(NSNotification*) aNotification {
        [player stop];
        [self dismissMoviePlayerViewControllerAnimated];
        [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerWillExitFullscreenNotification object:player];
    }
    
    [​IMG]
     
  2. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #2
    NSLog the self.view.frame you are assigning, that should explain alot :)
     

Share This Page