title: AVPlayer not full screen in landscape mode using iOS swift
body: <p>I have a video view set to full screen. However while playing in the simulator, it is not running full screen. </p>
  
  <p>This issue is only for iPads and not iPhones. </p>
  
  <p>Here is my code:</p>
  
  <pre><code>override func viewDidAppear(_ animated: Bool) {
  
      super.viewDidAppear(true)
  
      let bundle: Bundle = Bundle.main
      let videoPlayer: String = bundle.path(forResource: "normalnewer", ofType: "mp4")!
      let movieUrl : NSURL = NSURL.fileURL(withPath: videoPlayer) as NSURL
      //        var fileURL = NSURL(fileURLWithPath: "/Users/Mantas/Desktop/123/123/video-1453562323.mp4.mp4")
      playerView = AVPlayer(url: movieUrl as URL)
  
      NotificationCenter.default.addObserver(self,selector: #selector(playerItemDidReachEnd),name: NSNotification.Name.AVPlayerItemDidPlayToEndTime,object: self.playerView.currentItem) // Add observer
  
              var playerLayer=AVPlayerLayer(player: playerView)
  //        self.avPlayerLayer.playerLayer = AVLayerVideoGravityResizeAspectFill
  
  
      playerLayer.frame = viewVideo.bounds
  //        self.playerLayer.frame = self.videoPreviewLayer.bounds
  
      viewVideo.layer.addSublayer(playerLayer)
  
  
  
  
      playerView.play()
  
      UserDefaults.standard.set("normalnewer", forKey: "video")
  
  
  
  
  }
  </code></pre>
  
  <p>I have tried checking landscape mode in target's general. 
  Gone through the threads below:
  <a href="https://stackoverflow.com/questions/34043205/how-to-play-a-video-in-fullscreen-mode-using-swift-ios">how to play a video in fullscreen mode using swift ios?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/36759996/play-video-fullscreen-in-landscape-mode-when-my-entire-application-is-in-lock-i">Play video fullscreen in landscape mode, when my entire application is in lock in portrait mode</a></p>
  
  <p><a href="https://stackoverflow.com/questions/25651969/setting-device-orientation-in-swift-ios">Setting device orientation in Swift iOS</a></p>
  
  <p>But these did not resolve my issue. 
  Here is a screenshot.
  <a href="https://i.stack.imgur.com/TARXB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TARXB.png" alt="Screenshot of the error"></a></p>
  
  <p>Can somebody help me resolve this?</p>