I'm trying to add custom buttons to the left and right of the standard rewind/play/forward controls in an MPMoviePlayerController view (OS 2.x and up). I've figured out how to add them to the player window, but they're always visible. Is there a way to detect when the standard controls appear and disappear?
Ok, got it, make like this:
BOOL controlsVisible = NO;
for(id views in [[_moviePlayer view] subviews]){
for(id subViews in [views subviews]){
for (id controlView in [subViews subviews]){
controlsVisible = ([controlView alpha] <= 0.0) ? (NO) : (YES);
}
}
}
NSLog(@"player controls are visible: %d", controlsVisible);
Where _movePlayer is your instance of the player. In the deepest loop, the MPFullScreenVideoOverlay view instance will have alpha == 0.0 if the controls are hidden, or alpha 1.0 if the controls are shown. You can add an observer and fire things as needed. I know is not elegant but it works for me, as Apple has not documented anything regarding this task.
Cheers ...
cybercow's answer is right just have to add little modification to make the answer more accurate.
BOOL controlsVisible = NO;
for(id views in [[self.moviePlayerViewController view] subviews])
{
for(id subViews in [views subviews])
{
for (id controlView in [subViews subviews])
{
if ([controlView isKindOfClass:[UIView class]] && ((UIView*)controlView).tag == 1004)
{
controlsVisible = ([controlView alpha] <= 0.0) ? (NO) : (YES)
}
}
}
}
i changed the most inner loop. Actually 1004 is the tag of MPMoviePlayer controls so it will work more accurately.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With