AVPlayer videoGravity AVLayerVideoGravityResizeAspectFill不能正常工作Swift2.2

Rom*_*nko 6 swift

请帮我AVPlayer.我需要在iPhone旋转时调整视频大小(横向).这是我的代码:

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)
}
Run Code Online (Sandbox Code Playgroud)

但是字符串:

playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill
Run Code Online (Sandbox Code Playgroud)

不起作用.

我还设置值AVLayerVideoGravityResizeAVLayerVideoGravityResizeAspect,但也有类似的结果...