cbbcloud
cbbcloud

Reputation: 479

Make AVPlayer full screen without letterboxing

I'm trying to display a video on a login screen as seen on apps like Spotify.

What I'm doing

To do this I'm using AVPlayer:

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

The videoView is a custom UIView class as described here.

I set the AVLayer's videoGravity to AVLayerVideoGravityResizeAspectFill:

self.videoView.playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill

The problem

However, my video is still letterboxed when I try to make it fill out the bounds of my view:

enter image description here

What I want

What I want is to have the video fill out the entire bounds without any black bars. I don't care if part of the video is clipped:

enter image description here

Additional information

When I looked at the deprecated MPMoviePlayerController's scaling mode property, I found the following description of the aspectFill property:

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

Judging from this description, this is the exact behaviour I want. However, as already stated my video gets letterboxed. Am I doing something wrong or has Apple stopped supporting this type of scaling? If I don't care about part of the video being clipped, do I have to implement this scaling myself?

Any help is appreciated, thank you.

Upvotes: 2

Views: 657

Answers (1)

cbbcloud
cbbcloud

Reputation: 479

Ok so this is a tad embarrassing. I finally realised that the video itself had the letter boxing baked into it :(. The scaling that the AVPlayer was doing was working just fine.

Upvotes: 5

Related Questions