MPMoviePlayer done button Clicked Change The UIView Height

I am using a MPMoviePlayer to display a video. I go into full screen and when the done button is clicked I want it to remove of the entire movie player from my view.

Right Now When I click The Done Button It Dismiss The MPMoviePlayer But It change The size Of My UIView Height. Is there any solution To remove MPMoviePlayer without affecting my View Size.


Create a videoPlayer view controller (MPMoviePlayerViewController subclass) and add it to your root view controller.

videoPlayerViewController = [[VideoViewController alloc] initWithContentURL:[NSURL fileURLWithPath:resourcePath]];
[rootViewController presentMoviePlayerViewControllerAnimated:videoPlayerViewController];
videoPlayer.controlStyle = MPMovieControlStyleFullscreen;

then add notifications:

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

then your method that gets called when the notification is received.

- (void) stopVideo:(NSNotification*) aNotification {
  [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:[videoPlayerViewController moviePlayer]];
  [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerDidExitFullscreenNotification object:[videoPlayerViewController moviePlayer]];
  MPMoviePlayerController *player = [aNotification object];
  [player stop];

Need Your Help

Div alignment side by side height issue

css html height responsive-design

I am laying out product images inside a div using:

How to constrait a generic class to work with just two classes

c# .net generics constraints communication

I have a generic class modeling a protocol that encapsulates other protocols. All the protocols implement a specific interface but this generic class must contain only one of two of these protocols...