1

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...

Community
  • 1
  • 1
Jack
  • 81
  • 2
  • 9

1 Answers1

1

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.

Community
  • 1
  • 1
rkyr
  • 3,131
  • 2
  • 23
  • 38
  • Not working ... Please provide me any tutorial with AVPlayer, FullScreen ,Swift , AutoLayout – Jack Dec 01 '15 at 08:48
  • @Jack can you get more details? What you want and what you get. – rkyr Dec 01 '15 at 08:52
  • Yeah, I need a UIView in landscape mode and It should occupy full Screen and I should display AvPlayer Video in that view as fullscreen... – Jack Dec 01 '15 at 08:54
  • @Jack, to achieve your goal I follow [this](https://developer.apple.com/library/prerelease/ios/documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/02_Playback.html) tutorial. But it's on Obj-C. If you will need help with transporting this code to Swift - let me know. I've got ported code for my project. – rkyr Dec 01 '15 at 09:09
  • Hi did you port the code to Swift? Having trouble with this question, though it may be different as all we want to do is capture and render at the same size: http://stackoverflow.com/questions/34704032/swift-video-records-at-one-size-but-renders-at-wrong-size – Crashalot Jan 10 '16 at 09:48