title: How to resume audio playing of other apps after dismissing AVPlayerViewController?
body: <p>I use <code>AVPlayerViewController</code> to play short videos in my app.</p>
  
  <p>If there is an app playing audio in background before user plays a video in my app, I want the background audio playing of the other app to resume after my video player is dismissed. I currently use <code>AVAudioSession.setActive(false, with: .notifyOthersOnDeactivation)</code> to do that. </p>
  
  <p>Even though Apple's Music app and Podcasts app do resume playing after I call <code>AVAudioSession.setActive(false, with: .notifyOthersOnDeactivation)</code>—won't resume without the call so it means this call does have effect—none of the 3rd party music or podcast apps that I tested(Spotify, SoundCloud, Amazon Music, Overcast) do.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>override func viewDidAppear(_ animated: Bool) {
      super.viewDidAppear(animated)
  
      // I know it's not the best place to call setActive nor it covers all the cases. It's just a convenient place to put the code to test its effect after dismissing the video player.
      do {
          try AVAudioSession.sharedInstance().setActive(false, with: .notifyOthersOnDeactivation)
      } catch {
          print(error)
      }
  }
  
  @IBAction func play(_ sender: Any) {
      do {
          try AVAudioSession.sharedInstance().setActive(true)
      } catch {
          print(error)
      }
  
      let playerController = AVPlayerViewController()
      playerController.player = AVPlayer(url: URL(string: "http://gslb.miaopai.com/stream/UkjiD45ddxZFQ79I2bLaGg__.mp4")!)
      playerController.player?.play()
      present(playerController, animated: true)
  }
  </code></pre>
  
  <p>At first I thought it might be these 3rd party apps' fault. But then I tested them with the official Twitter app and found they can resume audio playback after video playing in Twitter app. </p>
  
  <p>So what did I miss? What should I do to make these 3rd party apps resume audio playback after video playing in my app, just as Twitter app does?</p>
  
  <p>PS: here is the complete <a href="https://cloudup.com/cTrxy7AcpUV" rel="nofollow noreferrer">project</a> so anyone interested can try it.</p>