title: Sound not playing when App in background (prepareToPlay returns NO)
body: <p>I've got a strange problem using AVAudioPlayer to play sound files (wav files) on an iPhone in the Background. I am using the following code:</p>
  
  <pre><code>        AVAudioPlayer* audioplayer;
          NSError* error;
  
          audioplayer = [[AVAudioPlayer alloc] initWithData:soundfile error:&amp;error];
          if (error) {
              NSLog(@"an error occured while init audioplayer...");
              NSLog(@"%@", [error localizedDescription]);
          }
          audioplayer.currentTime = 0;
          if (![audioplayer prepareToPlay])
              NSLog(@"could not preparetoPlay");
  
          audioplayer.volume = 1.0;
  
          [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
          [[AVAudioSession sharedInstance] setActive: YES error: &amp;error];
  
          if (![audioplayer play])
              NSLog(@"could not play sound");
  
          audioplayer.delegate = [myApp sharedInstance];
  </code></pre>
  
  <p>This works fine while the app is in foreground. However, when moving the app to background [audioplayer prepareToPlay] returns NO.</p>
  
  <p>This happens with AND without "App plays audio" added to the "Required background modes". Is there a way how to get a more precise error report from [audioplayer prepareToPlay]? Or do you have any hints what I am doing wrong or forgot?</p>