title: how to play a video in UIView swift?
body: <p>I have a video which I want to download from a server and stream it in a fixed view.
  I've set a UIView in my storyboard with fixed constraints, and here is what I've done in code:</p>
  
  <pre><code>@IBOutlet weak var videoView: UIView!
  var player: AVPlayer!
  var avpController = AVPlayerViewController()
  </code></pre>
  
  <p>And in my <code>viewDidLoad</code> I've done this:</p>
  
  <pre><code>let url = URL(string:myURL)
  player = AVPlayer(url: url!)
  
  avpController.player = player
  avpController.videoGravity = AVLayerVideoGravity.resizeAspect.rawValue
  self.addChildViewController(avpController)
  avpController.view.frame = videoView.frame
  self.containerView.addSubview(avpController.view)
  videoView.layer.masksToBounds = true
  </code></pre>
  
  <p>My problem is my video is not with the size that I've set to <code>videoView</code>  and in every device my video is in a different size. In some devices, the video height is larger than the height that I've set and it overlays the items that I have below <code>videoView</code>. How can I play video in a view in a right way?</p>