Add button to top or bottom bars of AVPlayerViewController

Viewed 396

I am wondering on how to add my own custom UIButton (or UIBarButtonItem)for Airplay or chrome cast? to the top or bottom bar of an AVPlayerViewController. Is this possible? If so, is there another way to add a custom button so it looks like it belongs in an AVPlayerViewController?

1 Answers

One possible solution is to embed the AVPlayerViewController in a navigation controller. If you do this, you can add UIBarButtonItems to the navigation bar at the top of the screen. You can then add an action handler to an AVPlayerViewController subclass that you assign to the AVPlayerViewController in your storyboard. One caveat is that I think the docs warn against subclassing AVPlayerViewController but I kind of doubt Apple is worried about adding an action handler for a UIBarButtonItem. If you are worried about subclassing an AVPLayerViewController, you could embed the AVPlayerViewController in a regular UIViewController instead.

Related