iosobjective-cavplayeravplayerviewcontrollersetuserinteractionenabled

How to set userinteractionEnabled: to NO for an AVPlayerViewController?


I try to set userinteractionEnabled: to NO for an AVPlayerViewController

[playerViewController setUserInteractionEnabled:NO];

but I have an error

"No visible @interface for 'AVPlayerViewController' declares the selector 'setUserInteractionEnabled:'"

No visible @interface Here is my complete code:

AVPlayer *player = [AVPlayer playerWithURL:videoURL];
AVPlayerViewController *playerViewController = [AVPlayerViewController new];
playerViewController.player = player;
  playerViewController.showsPlaybackControls = false;    
    [playerViewController.player play];
[playerViewController setUserInteractionEnabled:NO];
    [self.navigationController pushViewController:playerViewController animated:YES];
[self performSelector:@selector(popToMain) withObject:nil afterDelay:durationInSeconds];

I just would like the people cannot click on the screen during the video.

Thanks in advance.


Solution

  • Try this:

     [[UIApplication sharedApplication] beginIgnoringInteractionEvents];
     [[UIApplication sharedApplication] endIgnoringInteractionEvents];
    

    or this:

     playerViewController.view.userInteractionEnabled = NO;