AVPlayer videoGravity AVLayerVideoGravityResizeAspectFill doesn't work Swift2.2
<p>Please help me with AVPlayer. I need resize video when iPhone rotate (landscape orientation). Here is my code:</p>

<pre><code>var player: AVPlayer?

override func viewDidLoad() {
    super.viewDidLoad()

    // Load the video from the app bundle.
    let videoURL: NSURL = NSBundle.mainBundle().URLForResource("bg_animate", withExtension: "3gp")!

    player = AVPlayer(URL: videoURL)
    player?.actionAtItemEnd = .None
    player?.muted = true

    let playerLayer = AVPlayerLayer(player: player)
    playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill
    playerLayer.zPosition = -1
    playerLayer.frame = view.frame
    view.layer.addSublayer(playerLayer)
    player?.play()

    //loop video
    NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(ViewController.loopVideo), name: AVPlayerItemDidPlayToEndTimeNotification, object: nil)
}
</code></pre>

<p>But string:</p>

<pre><code>playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill
</code></pre>

<p>doesnt work. </p>

<p>I also set value as <code>AVLayerVideoGravityResize</code> and <code>AVLayerVideoGravityResizeAspect</code>, but had similar results...</p>