title: AVPlayer stops playing video after buffering
body: <p>When I load a video from the internet (10-40MB large) I am unable to provide a smooth playing experience.</p>
  
  <p>My AVPlayer either loads the whole video and then plays it, or plays 1s, buffers and then just stops playing. </p>
  
  <p>I tried endless libraries, buffer-observer methods, and tutorials. Nothing seems to help.</p>
  
  <pre><code>    .
      .
      .
  
      self.makeLoaderVisible()
  
      let playerItem = AVPlayerItem(url: url)
      playerItem.addObserver(self, forKeyPath: "playbackBufferEmpty", options: .new, context: nil)
      playerItem.addObserver(self, forKeyPath: "playbackLikelyToKeepUp", options: .new, context: nil)
      playerItem.addObserver(self, forKeyPath: "playbackBufferFull", options: .new, context: nil)
  
      avPlayer?.replaceCurrentItem(with: playerItem)
      avPlayer?.automaticallyWaitsToMinimizeStalling = false
      avPlayer?.playImmediately(atRate: 0)
  //  avPlayer?.play()
  
      }
  
  
  override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
      if object is AVPlayerItem {
          switch keyPath! {
          case "playbackBufferEmpty":
              // Show loader
              makeLoaderVisible()
  
          case "playbackLikelyToKeepUp":
              // Hide loader
              hideLoader()
  
          case "playbackBufferFull":
              // Hide loader
              hideLoader()
  
          default:
              return
          }
      }
  }
  </code></pre>