How to set userinteractionEnabled: to NO for an AVPlayerViewController?

202 Views Asked by At

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.

2

There are 2 best solutions below

1
On BEST ANSWER

Try this:

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

or this:

 playerViewController.view.userInteractionEnabled = NO;
0
On

Maybe this might help you:

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