Jack
Jack

Reputation: 81

Video Full Screen not Working in ios Swift AVPlayer?

This is my code:

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

First line to transform from portrait to landscape... mp is AVPlayer..

Storyboard pic and black color is the playerView inside ViewController MainView

enter image description here

and the constraints are

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

The output is: View is not Occupying the full screen but leaving some space at left and right

enter image description here

Somebody help please? Atleast Provide some tutorial...

Upvotes: 1

Views: 3119

Answers (1)

rkyr
rkyr

Reputation: 3241

This is because of AVLayerVideoGravityResizeAspectFill that you specify when initialize your playerView. According to docs:

AVLayerVideoGravityResizeAspectFill

Specifies that the player should preserve the video’s aspect ratio and fill the layer’s bounds.

Upvotes: 1

Related Questions