2

I'm making a mac app that plays a video using AVPlayerView. I want to control the player programmatically. I've set the controlStyle to none, so that the user can't press the buttons to control the player.

theplayer.controlsStyle = AVPlayerViewControlsStyleNone;

You can't use the buttons now but when you press the space bar you can still pause it. Or when you press the arrow keys you can still control the player.

So is there a way to disable all user interaction?

Developer
  • 406
  • 1
  • 4
  • 18
  • 1
    `AVPlayer` doesn't have a controlStyle property. Are you using something else? Can you show some code? – Rhythmic Fistman Jan 08 '17 at 23:22
  • @RhythmicFistman I meant AVPlayerView. I thought it was just called AVPlayer but thanks for pointing out the mistake. I also added the code. – Developer Jan 10 '17 at 19:14

1 Answers1

2

You can subclass AVPlayerView and override acceptsFirstResponder to return NO:

// .h file
@interface NonRespondingAVPlayerView : AVPlayerView

@end

// .m file
@implementation NonRespondingAVPlayerView

- (BOOL)acceptsFirstResponder {
    return NO;
}

@end
Rhythmic Fistman
  • 34,352
  • 5
  • 87
  • 159