问题描述
我正在和苹果电视一起工作.我的UIViewController中有一个UIView.我将AVPlayerViewController添加为UIView的子视图. UIView的框架为CGRect(x:50,y:50,宽度:1344,高度:756).我将AVPlayerViewController框架设置为等于UIView框架.
I am working with apple tv. I have a UIView inside my UIViewController. I am adding AVPlayerViewController as subview of my UIView. UIView's frame is CGRect(x: 50, y: 50, width: 1344, height: 756). I am setting AVPlayerViewController frame equals to my UIView's frame.
问题是视频在其帧中播放正常,但是诸如暂停,播放,前进等控件被隐藏并且无法正常工作.但是,当我将frame设置为CGRect(x:0,y:0,width:1920,height:1080)时,控件是可见的并且可以正常工作.
我的代码如下:
let url = URL(string: "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")
let item = AVPlayerItem(url: url!)
self.player = AVPlayer(playerItem: item)
self.avplayerController = AVPlayerViewController()
self.avplayerController.player = self.player
self.avplayerController.view.frame = videoPreviewLayer.frame
self.avplayerController.showsPlaybackControls = true
self.avplayerController.requiresLinearPlayback = true
self.addChildViewController(self.avplayerController)
self.view.addSubview(self.avplayerController.view)
self.avpController.player?.play()
请帮助.
推荐答案
这是预期的行为:
您可以在以下线程上了解更多有关此内容: https://forums.developer.apple. com/thread/19526
You can read more about this on this thread: https://forums.developer.apple.com/thread/19526
这篇关于视图内的AVPlayerViewController未显示播放控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!