0

I have an AVPlayerViewController with an AVPlayer inside. By default the playback controls appear on the bottom of the view, is there a way to make them appear on top of the view instead?

JAL
  • 41,701
  • 23
  • 172
  • 300
Alk
  • 5,215
  • 8
  • 47
  • 116

2 Answers2

2

There's no supported built-in way. You'd have to roll your own controls to do that.

Also keep in mind that the AVPlayerViewController's view doesn't have to occupy the whole screen. So the controls may appear at the bottom of the view but that doesn't mean they have to appear at the bottom of the screen. Design around the view so that it doesn't interfere with your other interface.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • Isn't there a way to just access the view which has the controls embedded in them and change its position or constraints? – Alk Jun 22 '16 at 16:26
  • I see you edited your answer, but that didn't really help with my followup question – Alk Jun 22 '16 at 16:30
  • Yes it did. My answer stands. Which part of "There's no supported built-in way" fails to answer the question? Sure, you can mess with the controls however you like, but don't try to get that into the app store. My advice: take what you're given and move on. – matt Jun 22 '16 at 16:49
  • I don't think this is too much of an abstract request, the design of my app simply doesn't permit me too keep the controls on the bottom of the screen since I have other views positioned there. I think this should be something that should be customizable by default... – Alk Jun 22 '16 at 16:52
  • Sure, I agree totally, it should be. But it isn't. Programming Cocoa is about reality, not your dreams and my dreams. File a bug with Apple requesting this feature. Meanwhile, move on. — You do not have to keep the controls at the bottom of the _screen_. You have to keep them at the bottom of the view controller's _view_. Those are not the same thing! You seem to imagine that the view controller's view has to occupy the whole screen. It doesn't. – matt Jun 22 '16 at 16:57
  • My view has a `UIView` with a blur effect which takes up the bottom 100 pixels of the screen. This `UIView`is overlayed on top of the `AVPlayerViewController`, the whole idea is that the video plays in the background while the blur effect is applied on the video. At the moment, the controls are behind my `UIView`. I tried placing the whole view above the `UIVIew` which works fine, however then I have a black screen behind the blur, which beats the purpose. – Alk Jun 22 '16 at 17:02
  • 1
    But that isn't what you asked. I answered - correctly - the question you _did_ ask. – matt Jun 22 '16 at 17:11
1

AVPlayerViewController has a private UIView *_controlsView which holds the control rack. You could iterate through the subviews of the view controller or create an interface which exposes this property to get a reference to it.

As this is an undocumented view, use caution when messing with private properties. The player might not even support moving the _controlsView around.

I'd also look into the AVPlaybackControlsViewController *_playbackControlsViewController; property if the _controlsView does not exactly fit your needs.

AVPlayerViewController private header (for reference).

JAL
  • 41,701
  • 23
  • 172
  • 300