AVPlayerViewController inside a view is not showing the playback controls

廉价感情. 提交于 2019-12-04 17:27:17

This is an expected behaviour:

AVPlayerViewController is designed such that when in full screen, the full playback experience (scrubbing, info panel access, etc) are all available. When in a space less than full screen, the assumption is that it is just one of several interactive elements on screen, and thus the view should not absorb all touch surface events as transport control.

You can read more about this on this thread: https://forums.developer.apple.com/thread/19526

I managed to solve this using this code:

let player = AVPlayer(url: self.videoUrl!)
let avPlayerController = AVPlayerViewController()

avPlayerController.player = player;
avPlayerController.view.frame = self.videoPlayView.bounds;

self.addChildViewController(avPlayerController)
self.videoPlayView.addSubview(avPlayerController.view);

Now AVPlayerViewController shows most playback controls even as child to a uiview.

Courtesy: https://www.techotopia.com/index.php/IOS_8_Video_Playback_using_AVPlayer_and_AVPlayerViewController

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!