title: How to keep AVPlayer video playing when app goes background
body: <p>I'm trying to keep the video in AVPlayer playing when app goes background, but it always stops. I use Swift. I've found a lot of examples, but nothing works.</p>
  
  <p>I've turned on "App plays audio or streams audio/video using AirPlay" in Info.plist and added this code to the didFinishLaunchingWithOptions in AppDelegate:</p>
  
  <pre><code>do {
      try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
  }
  catch {
      /*Error*/
  }
  </code></pre>
  
  <p>What is the proper way to keep video playing?</p>