user2019279
user2019279

Reputation: 163

MPMoviePlayerViewController issue

I am trying to add subview MPMoviePlayerViewController object, its top bar moves little bit down, but if i do presentView the MPMoviePlayerViewController object its perfect. ? I dont know whats happening. Please help me out .

if i an adding on subview i am writing :

      self.moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL       URLWithString:self.filePath]];
       [self.moviePlayer.view setFrame:self.view.bounds];
      [self.view addSubview:self.moviePlayer.view];

so top default done button and progress bar moves little bit down. Please help me , Why this is happening ? and solution for this.

Upvotes: 0

Views: 809

Answers (2)

Nag_iphone
Nag_iphone

Reputation: 967

    MPMoviePlayerController* movieController = [[MPMoviePlayerController alloc] 
                                                initWithContentURL:url];

    movieController.view.frame = self.window.bounds;
    movieController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;   
    [self.window addSubview:movieController.view];

    [movieController prepareToPlay];
    [movieController setShouldAutoplay:NO];

Upvotes: 1

user2197398
user2197398

Reputation:

Try this:

self.moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL       URLWithString:self.filePath]];

CGRect frame = self.view.bounds;
frame.origin.y -= 20;
[self.moviePlayer.view setFrame:frame];
[self.view addSubview:self.moviePlayer.view];

The MPMoviePlayerViewController view frame is assuming that it will display with the status bar visible, but I am assuming you have hidden your status bar. So when you add the MPMoviePlayerViewController view, its frame.origin.y is set to 20 (status bar height).

Upvotes: 0

Related Questions