title: iphone background audio on/off
body: <p>I have an application that can play audio while the application is in the background with the entry in the plist and everything work fine.
  But I would like to give the option to the user to setup the background play on and off
  I use this method to activate the player</p>
  
  <pre><code>moviePlayer.useApplicationAudioSession = YES;
  [moviePlayer play];
  [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:NULL];
  [[AVAudioSession sharedInstance]  setActive:YES error:NULL];
  </code></pre>
  
  <p>I would like to change this option on run time and without any interruptions to the audio play.
  Any ideas if this can happen?</p>
  
  <p>Thanks for your time</p>
  
  <p>I will post the solution here to make it better</p>
  
  <pre><code>if (backgroundSwitch.on) { 
      [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:NULL];
  }else { 
      [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategorySoloAmbient error:NULL];
  }
  </code></pre>