MPMoviePlayerController adds a UIButton for viewing, which disappears with controls

I am trying to add a UIButton to the MPMoviePlayerController view along with standard controls. A button appears above the video and works as expected to receive touch events, but I would like it to disappear and exit with standard controls in response to user touches.

I know that I can accomplish this by copying my own custom player controls, but it seems silly since I'm just trying to add a single button.

EDIT

If you recursively go through the hierarchy of representations of the MPMoviePlayerController view, you end up with a class of the form MPInlineVideoOverlay. You can easily add any additional controls to this view to achieve automatic stroking of the input / output.

However, there are several fixes, sometimes it may take some time (before my experience), after creating the MPMoviePlayerController and adding it to the view until it is fully initialized and the MPInlineVideoOverlay layer is created. Because of this, I had to create an instance variable called controlView in the code below, because sometimes it does not exist when this code works. That's why I have the last bit of code where the function calls itself again after 0.1 seconds if it is not found. I did not notice the notes on the button appearing on my interface, despite this delay.

-(void)setupAdditionalControls {
    //Call after you have initialized your MPMoviePlayerController (probably viewDidLoad)
    controlView = nil;
    [self recursiveViewTraversal:movie.view counter:0];

    //check to see if we found it, if we didn't we need to do it again in 0.1 seconds
    if(controlView) {
            UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
            [controlView addSubview:backButton];
    } else {
            [self performSelector:@selector(setupAdditionalControls) withObject:nil afterDelay:0.1];
    }
}


-(void)recursiveViewTraversal:(UIView*)view counter:(int)counter {
    NSLog(@"Depth %d - %@", counter, view); //For debug
    if([view isKindOfClass:NSClassFromString(@"MPInlineVideoOverlay")]) {
            //Add any additional controls you want to have fade with the standard controls here
            controlView = view;
    } else {
            for(UIView *child in [view subviews]) {
                    [self recursiveViewTraversal:child counter:counter+1];
            }
    }
}

, , - . Apple , , . , ( ). , , MPInlineVideoOverlay : iPad MPMoviePlayerController -

setupAdditionalControls, , , .

, - - , , .

+3
1

:

  • MPMoviePlayerController;
  • alpha ;
  • touchesBegan ( );
  • , , .

, , () iOS, :

  • fade in: 0.1s
  • : 0.2s
  • : 5.0 (, , )

, ; , , .

+5

All Articles