swiftmacosavplayernstouchbar

How to remove touchbar AVPlayer created automatically in Swift


I'm programming a mac app and I want to support the touchbar. I have a split screen controller and in one of the views is a AVPlayer. The AVPlayer automatically created touchbar buttons for pause and play etc. how can I remove this touchbar that's automatically created? Or is there a way to disable the touchbar for a viewcontroller? I want to add one touchbar for the window in the windowcontroller and at the moment it is overwritten by the touchbar that's automatically crated by AVPlayer.


Solution

  • Try creating your touchbar on the NSWindow itself and add an .otherItemsProxy item to the default identifiers:

    [.stuff, .thing, .otherItemsProxy]
    

    This way the AVPlayer touchbar should insert itself in the window's one (I don't think you can replace the AVPlayer one with yours).

    The idea is that the touchBars are prioritized like this: first the AppDelegate, then the NSWindow, then the NSView, then the subviews, etc.

    So if you have a touchBar with a proxy at the window level, then the items at the view level should insert themselves where the .otherItemsProxy is.