title: Swift AVPlayer continuously loads when trying to play url video file
body: <p>I am attempting to play a video file from a youtube url. I have created the AVPlayer and linked the url to the player. The player opens when I click the button, but the video player just shows the file continuously loading. I have changed the App Transport Security Settings -> Allow Arbitrary Loads on the plist.</p>
  
  <p>Heres the code:</p>
  
  <pre><code>@IBAction func playVideo(_ sender: Any) {
  
  
      let movieId = "xLCn88bfW1o"
      let path = URL(string: "https://www.youtube.com/watch?v=\(movieId)")
      let video = AVPlayer(url: path!)
      let videoPlayer = AVPlayerViewController()
      videoPlayer.player = video
  
      present(videoPlayer, animated: true, completion: {
          video.play()
      })
  
  }
  </code></pre>
  
  <p><img src="https://ibb.co/kKKq6z" alt="Loading Video Player"></p>
  
  <p>EDIT: I've also tried by using the URL for sharing the video; <a href="https://youtu.be/xLCn88bfW1o" rel="nofollow noreferrer">https://youtu.be/xLCn88bfW1o</a>.</p>