这是我的代码:
self.playerView?.transform = CGAffineTransformMakeRotation(CGFloat(M_PI_2));
self.playerView?.setVideoGravity(AVLayerVideoGravityResizeAspectFill)
self.playerView?.setMovieToPlayer(mp)
第一行从纵向转换为横向... mp 是 AVPlayer..
Storyboard图片和黑色是 ViewController MainView
中的 playerView
约束是
trailing = Player View.trailing
Player View.bottom = Bottom Layout Guide.top
Player View.top = top
Player View.leading = leading
输出结果为:View未占全屏,左右留有空间
有人帮忙吗? 至少提供一些教程...
最佳答案
这是因为您在初始化 playerView
时指定了 AVLayerVideoGravityResizeAspectFill
。根据docs :
AVLayerVideoGravityResizeAspectFill
Specifies that the player should preserve the video’s aspect ratio and fill the layer’s bounds.
关于ios - 视频全屏在 ios Swift AVPlayer 中不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34014121/