使AVPlayer全屏无信箱

Make AVPlayer full screen without letterboxing

我正在尝试在登录屏幕上显示在 Spotify 等应用程序中看到的视频。

我在做什么

为此,我使用了 AVPlayer:

self.videoPlayer = AVPlayer(playerItem: item)
self.videoView.player = self.videoPlayer
self.videoPlayer.play()

videoView 是自定义 UIView class,如 here 所述。

我将 AVLayer 的 videoGravity 设置为 AVLayerVideoGravityResizeAspectFill:

self.videoView.playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill

问题

但是,当我尝试填充我的视图边界时,我的视频仍然有信箱:

我想要的

我想要的是让视频填满整个边界,没有任何黑边。我不在乎视频是否被剪掉了:

附加信息

当我查看 deprecated MPMoviePlayerController's scaling mode property 时,我发现 aspectFill 属性 的描述如下:

Scale the movie uniformly until the movie fills the visible bounds of the view. Content at the edges of the larger of the two dimensions is clipped so that the other dimension fits the view exactly. The aspect ratio of the movie is preserved

从这个描述来看,这正是我想要的行为。但是,如前所述,我的视频被信箱化了。我是在做错什么,还是 Apple 已经停止支持这种类型的缩放?如果我不关心视频的一部分被剪辑,我是否必须自己实现这种缩放?

感谢任何帮助,谢谢。

好吧,这有点尴尬。我终于意识到视频本身已经融入了字母装箱:(。AVPlayer 所做的缩放工作得很好。