0

as the title,when i play movie using moviePlayer I want to know when the playControllerBar will be dismiss,so that i can control my view added in moviePlayer . Is there anyone know that? Tell me ,thanks .

ben
  • 1,020
  • 1
  • 15
  • 27
  • I work at Iphone os3.2,the tag Iphone os3.0 must be a mistake,i really want know how did it work at Iphone os3.2. The playControllerBar is what i meant the bar has pause,play,forward,backward,and playback rate bar . – ben Jul 02 '10 at 01:34
  • MPMovieControlStyleFullscreen – ben Jul 02 '10 at 01:43

1 Answers1

1

I'm not 100% sure if I understand you correctly. I assume that what you want to do is:

  1. play a movie
  2. add a custom view (overlay) on top of the (running) movie.

assuming what i just wrote down, I think you have to consider the following things:

  1. adding a custom overlay on top of MPMoviePlayerViewController is (as far as I'm concerned) only allowed/possible if the standard player controls are set to none:

    [moviePlayerViewController.moviePlayer setControlStyle:MPMovieControlStyleNone];
    
  2. adding your custom overlay on top of the player is basically the same addSubview procedure as on any other view

    [moviePlayerViewController.view addSubview:overlay];
    

the above code / concept will work on 3.2 and later, as i just read now you're obviously developing for 3.0

rather then deleting the first part of my answer i will now explain how to achieve the same effect on 3.0

on 3.0 it's a bit trickier (as you sure know by now). MPMoviePlayerController is not a view Controller and works only in fullscreen-mode. Once the movie starts playing, the keyWindow changes! so We make use of that by implementing the following:

1) within your Class that encapsulates the MPMoviePlayerController, start listening to the UIWindowDidBecomeKeyNotification by doing the following:

        [[NSNotificationCenter defaultCenter] addObserver: self 
                                             selector: @selector(keyWindowChanged:) 
                                                 name: UIWindowDidBecomeKeyNotification 
                                               object: nil];

2) withing your keyWindowChanged: Method you can add your overlay, the following snipplet is exactly how I implemented it:

- (void)keyWindowChanged: (id) sender {

//NSLog(@"keyWindowChanged");
[[NSNotificationCenter defaultCenter] removeObserver: self name: UIWindowDidBecomeKeyNotification object: nil];
UIWindow *moviePlayerWindow = [[UIApplication sharedApplication] keyWindow];

[moviePlayerWindow addSubview: overlayController.view];
[overlayController performSelector:@selector(fadeIn)]; 

}

again, this only works if the MovieControllMode is "hidden" by doing that:

[newMPController setMovieControlMode: MPMovieControlModeHidden];

I hope I could help.

samsam
  • 3,125
  • 24
  • 40