简体   繁体   中英

Change position of AVPlayerViewController controls

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?

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.

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM