How to detect touches on MPMoviePlayerController window and still having the standard playback controlling
I have the MPMoviePlayerController set up to play a movie.I want to detect a touch on the movie for bringing up few buttons.I used the code :
// The movie's window is the one that is active
UIWindow* moviePlayerWindow = [[UIApplication sharedApplication] key开发者_StackOverflow社区Window];
// Now we create an invisible control with the same size as the window
UIControl* overlay = [[[UIControl alloc] initWithFrame:moviePlayerWindow.frame]autorelease];
// We want to get notified whenever the overlay control is touched
[overlay addTarget:self action:@selector(movieWindowTouched:) forControlEvents:UIControlEventTouchDown];
// Add the overlay to the window's subviews
[moviePlayerWindow addSubview:overlay];
but then the play back controllers doesn't appear , I guess because the player window doesn't get the touch.how can I keep the player controllers and still detects touches? thanks
You have to create your own UIView's subclass and add it as overlay.
In the method -(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
you can do everything you want to do when the screen is touched.
I have done this in my project. I have implemented design of the VideoOverlay( the UIView's subclass) in Interface Builder. It is much easier when you have to add other elements that user have to interact with.
精彩评论