视图内的AVPlayerViewController未显示播放控件 [英] AVPlayerViewController inside a view is not showing the playback controls

查看:133
本文介绍了视图内的AVPlayerViewController未显示播放控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在和苹果电视一起工作.我的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()

请帮助.

推荐答案

这是预期的行为:

AVPlayerViewController的设计使得在全屏模式下, 完整的播放体验(擦洗,访问信息面板等)全部 可用的.当空间小于全屏时,假设为 它只是屏幕上几个互动元素之一,并且 因此,视图不应在传输过程中吸收所有触摸表面事件 控制.

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.

您可以在以下线程上了解更多有关此内容: https://forums.developer.apple. com/thread/19526

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

这篇关于视图内的AVPlayerViewController未显示播放控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆