I went through the example from apple \"MoviePlayer on iPhone\"
Im trying to overlay on top of the mpmovieplayercontroller,
it works perfectly with video cli
Previous answer was based on timer. & fixed 5 seconds.
When Movie player begins, a new window is added to application.
Use a timer to check weather a new window is added to your application or not.
When a window ( movie player window ) is added. set notifications.
-(void)viewDidLoad{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePreloadDidFinish:)
name:MPMoviePlayerContentPreloadDidFinishNotification
object:nil];
// Register to receive a notification when the movie has finished playing.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
// Register to receive a notification when the movie scaling mode has changed.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieScalingModeDidChange:)
name:MPMoviePlayerScalingModeDidChangeNotification
object:nil];
videoListController.xmlClassVideoList=t;
// here ttttt is a timer declared in .h file
tttttt=[NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(startMy) userInfo:nil repeats:YES];
}
-(void)startMy{
NSArray *windows = [[UIApplication sharedApplication] windows];
NSLog(@"%i",[windows count]);
// depends on your application window
// it may be 1/2/3
if ([windows count] > 3) {
// Locate the movie player window
[tttttt invalidate];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyWindowChanged:) name:UIWindowDidBecomeKeyNotification object:nil];
}
}