ios - 视频全屏在 ios Swift AVPlayer 中不起作用?

标签 ios swift avplayer

这是我的代码:

self.playerView?.transform = CGAffineTransformMakeRotation(CGFloat(M_PI_2));
self.playerView?.setVideoGravity(AVLayerVideoGravityResizeAspectFill)
self.playerView?.setMovieToPlayer(mp)

第一行从纵向转换为横向... mp 是 AVPlayer..

Storyboard图片和黑色是 ViewController MainView 中的 playerView

enter image description here

约束是

trailing = Player View.trailing
Player View.bottom = Bottom Layout Guide.top
Player View.top = top
Player View.leading = leading

输出结果为:View未占全屏,左右留有空间

enter image description here

有人帮忙吗? 至少提供一些教程...

最佳答案

这是因为您在初始化 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/

相关文章:

ios - iOS Tableview 中的多列

ios - 快速保存高分

swift - 在 Cocoa macos 应用程序中捕获 SIGINT

ios - swift 4如何控制多个按钮只高亮一个按钮?

ios - 在 Swift 中动态创建自定义按钮的实例

ios - 如何向导航栏添加两个栏按钮?遇到错误

ios - 使用 Swift 通过 segue 发送数据后消失

ios - Odd RTCReporting bug

ios - AVPlayer 不在 iOS 11 中播放

ios - 创建太多 AVPlayer 实例时出现 AVPlayerItemStatusFailed 错误