MpMovieplayerController tap gesture recognizer doesn't trigger when in fullscreen

I´m trying to use UITapGestureRecognizer in order to handle the taps on my fullscreen video. If I omit [self.player setFullscreen:YES animated:NO]; it works, but then my video won’t scale to fit the screen.

From my .m:

  • Selector to get indexPath UICollectionView Swift 3.0
  • Frontmost UIView with TapGestureRecognizer not receiving touches
  • How do I implement the UITapGestureRecognizer into my application
  • How to tap to zoom and double tap to zoom out in iOS?
  • UITapGestureRecognizer initWithTarget:action: method to take arguments?
  • Detect touch event on UIScrollView AND on UIView's components
  • - (void)viewDidLoad
    {
        [super viewDidLoad];
    
        NSString *videoPath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"mov"];
        player =  [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:videoPath]];
    
        player.shouldAutoplay = NO;
        player.view.frame = self.view.bounds;
        player.scalingMode = MPMovieScalingModeAspectFit;
        player.controlStyle = MPMovieControlStyleNone;
        player.fullscreen = YES;
        self.player = player;
        [self.player prepareToPlay];
    
        UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
        UIView *aView = [[UIView alloc] initWithFrame:player.view.bounds];
        [aView addGestureRecognizer:tapGesture];
        [self.player.view addSubview:aView];
    }
    
    - (IBAction)playMovie:(id)sender {
        //add the MPMoviePlayerViewController to this view (as subview)
        //Play movie
        [self.view addSubview:self.player.view];
        [self.player setFullscreen:YES animated:NO]; //commenting out this will make it work
        [self.player play];
    }
    
    - (void)handleTap:(UITapGestureRecognizer *)recognizer {
        NSLog(@"tap tap");
    }
    

    From my .h:

    @property (retain, nonatomic) MPMoviePlayerController *player;
    - (void)handleTap:(UITapGestureRecognizer *)recognizer;
    

    2 Solutions Collect From Internet About “MpMovieplayerController tap gesture recognizer doesn't trigger when in fullscreen”

    In my comment, I drafted how to get that covered when using proper fullscreen ([self.player setFullscreen:YES animated:NO];).

    I would suggest that instead you simply resize the player view to cover the entire screen by setting its frame accordingly.

    You initialising code would have to get rid of that player.fullscreen = YES;, but that I guess is obvious by now.

    You can try this:

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(willEnterFullScreen:)
                                                 name:MPMoviePlayerWillEnterFullscreenNotification
                                               object:nil];
    
    - (void)willEnterFullScreen:(NSNotification*)notification
    {
        UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
        UIView *aView = [[UIView alloc] initWithFrame:self.player.backgroundView.bounds];
        [aView addGestureRecognizer:tapGesture];
        [self.view.window addSubview:aView];
    }
    

    and then remove your subview when MPMoviePlayerWillExitFullscreenNotification is posted