AVPlayerView Mac: How to disable all user interaction?

501 views Asked by At

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?

1

There are 1 answers

0
Gordon Childs On BEST ANSWER

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