Question

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 .

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top