AVPlayerView Mac: How to disable all user interaction?


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?

Show source
| osx   | objective-c   | avplayerview   2017-01-06 17:01 1 Answers

Answers ( 1 )

  1. 2017-01-11 00:01

    You can subclass AVPlayerView and override acceptsFirstResponder to return NO:

    // .h file
    @interface NonRespondingAVPlayerView : AVPlayerView
    // .m file
    @implementation NonRespondingAVPlayerView
    - (BOOL)acceptsFirstResponder {
        return NO;
◀ Go back