AVPlayerView Mac: How to disable all user interaction?

Question

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 to AVPlayerView Mac: How to disable all user interaction? ( 1 )

  1. 2017-01-11 00:01

    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
    

Leave a reply to - AVPlayerView Mac: How to disable all user interaction?

◀ Go back