title: How do I get my AVPlayer to play while app is in background?
body: <p>I've done my homework... been reading here, the docs, googling, stackoverflowing... but still no luck in making my sound stick when the user makes the app go into the background.</p>
  
  <p>What I have done so far:
  Added the UIBackgroundModes, audio to the plist-file.</p>
  
  <p>First this code:</p>
  
  <pre><code>radioAudio = [[AVAudioSession alloc] init];
  [radioAudio setCategory:AVAudioSessionCategoryPlayback error:nil];
  [radioAudio setActive:YES error:nil];
  </code></pre>
  
  <p>Then this:</p>
  
  <pre><code>NSString *radioURL = @"http://xxx.xxx.xxx/radio.m3u";
  radioPlayer = [[AVPlayer playerWithURL:[NSURL URLWithString:radioURL]] retain];
  </code></pre>
  
  <p>But as soon as the user hits the home-button, my sound dies.</p>
  
  <p>I also found this, but not added yet cuase some stuff I've read says it is not needed;</p>
  
  <pre><code>newTaskId = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:NULL];
       if (newTaskId != UIBackgroundTaskInvalid &amp;&amp; bgTaskId != UIBackgroundTaskInvalid)
          [[UIApplication sharedApplication] endBackgroundTask: bgTaskId];
  bgTaskId = newTaskId;
  </code></pre>
  
  <p>Right now I have no idea where I should go to make my AVPlayer let the radio sing while the user does other stuff on the phone.
  I am testing this on an iPhone 4 with 4.2. Building it for 4.0.</p>
  
  <p>Anyone have any suggestions what I should do?</p>