简体   繁体   English

全屏视频无法在iOS Swift AVPlayer中使用?

[英]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.. 从肖像到风景的第一行... mp是AVPlayer ..

Storyboard pic and black color is the playerView inside ViewController MainView 故事板图片和黑色是ViewController MainViewplayerView

在此处输入图片说明

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 输出为:视图未占满整个屏幕,但在左侧和右侧保留了一些空间

在此处输入图片说明

Somebody help please? 有人帮忙吗? Atleast Provide some tutorial... Atleast提供一些教程...

This is because of AVLayerVideoGravityResizeAspectFill that you specify when initialize your playerView . 这是因为AVLayerVideoGravityResizeAspectFill您指定当初始化playerView According to docs : 根据文档

AVLayerVideoGravityResizeAspectFill AVLayerVideoGravityResizeAspectFill

Specifies that the player should preserve the video's aspect ratio and fill the layer's bounds. 指定播放器应保留视频的长宽比并填充图层的边界。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM