title: Playing YouTubePlayer Sound in Background Swift
body: <p>I'm using the YouTubeSDK to play YouTube videos in my app found here: <a href="https://github.com/gilesvangruisen/Swift-YouTube-Player" rel="nofollow">https://github.com/gilesvangruisen/Swift-YouTube-Player</a> </p>
  
  <p>However, when the user presses home I want the sound to keep playing in the background. 
  <a href="https://github.com/youtube/youtube-ios-player-helper/issues/38" rel="nofollow">https://github.com/youtube/youtube-ios-player-helper/issues/38</a></p>
  
  <p>I'm currently trying this in the <code>App Delegate</code> (awful conversion) in the <code>didFinishLaunchingWithOptions</code>: </p>
  
  <pre><code>let sessionEror:NSError?
  do {
  
      let playBG = try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback, withOptions: .DefaultToSpeaker)
  
  } catch let error as NSError  {
      print("ERROR")
  }
  </code></pre>
  
  <p>And this is in it's own function in the same file: </p>
  
  <pre><code>func playerView(YTPlayerView: YTPlayerState, didChangeToState: YTPlayerState) {
  
          switch {
  
          case YTPlayerState.Paused:
              YTPlayerState.Playing,
          break
          }
  
  
      }
  </code></pre>
  
  <p>Any idea how to keep playing the sound in the background using the YouTube SDK? Also, is it possible to just play the sound in the background and <strong>not</strong> the video?</p>
  
  <p>Any and all help is appreciated. </p>