Note that my answer is referring to MPMoviePlayerController
, not MPMoviePlayerViewController
. I would advise you to use it either directly or via its reference on MPMoviePlayerViewController
.
First of all, never ever add anything directly onto MPMoviePlayerController
's view. That is prone to have all kinds of weird side-effects and is clearly advised against in the documentation. Instead use its backgroundView
for hosting your custom stuff or the parent of MPMoviePlayerController
's view
(making it a sibling).
But then again, that won't solve the issue you describe with having that view/label/whatever dis/reappear together with the controls if the user taps or simply waits.
There are ways to do that, but I am afraid those are in the grey-zone - or in other words, have a chance of getting rejected by Apple. In fact its not just a grey-zone but a clear violation of Apple's development guidelines.
Just, I have used this trick in the past on major apps and never got detected/rejected.
First, you need to locate the interface-view of your MPMoviePlayerController instance.
/**
* This quirky hack tries to locate the interface view within the supposingly opaque MPMoviePlayerController
* view hierachy.
* @note This has a fat chance of breaking and/or getting rejected by Apple
*
* @return interface view reference or nil if none was found
*/
- (UIView *)interfaceView
{
for (UIView *views in [self.player.view subviews])
{
for (UIView *subViews in [views subviews])
{
for (UIView *controlView in [subViews subviews])
{
if ([controlView isKindOfClass:NSClassFromString(@"MPInlineVideoOverlay")])
{
return controlView;
}
}
}
}
return nil;
}
UIView *interfaceView = [self interfaceView];
Now that you got the instance, simply add your view/label/whatever onto that view.
[interfaceView addSubview:myAwesomeCustomView];