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

时间:2015-12-01 06:39:38

标签: ios swift avplayer

这是我的代码:

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

从纵向转变为景观的第一条线...... mp是AVPlayer ..

故事板图片和黑色是playerView

内的ViewController MainView

enter image description here

,约束是

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

输出为:视图不占用全屏但留下一些左右空间

enter image description here

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

1 个答案:

答案 0 :(得分:1)

这是因为您在初始化AVLayerVideoGravityResizeAspectFill时指定了playerView。根据{{​​3}}:

  

AVLayerVideoGravityResizeAspectFill

     

指定播放器应保留视频的宽高比并填充图层的边界。