title: Play and record video while playing some background music
body: <p>I looked in several forums and they all couldn't deliver a satisfying answer.</p>
  
  <p>My wish is to be able to play and record video while playing music at the background.
  I managed to do that with the help of a snippet I found. here is the code:</p>
  
  <pre><code>    AVAudioSession *session = [AVAudioSession sharedInstance];
  session.delegate = self;
  
  NSError *error = nil;
  [session setCategory:AVAudioSessionCategoryPlayAndRecord error:&amp;error];
  
  OSStatus propertySetError = 0;
  
  UInt32 allowMixing = true; 
  
  propertySetError = AudioSessionSetProperty (
  
                                              kAudioSessionProperty_OverrideCategoryMixWithOthers,  // 1
  
                                              sizeof (allowMixing),                                 // 2
  
                                              &amp;allowMixing                                          // 3
  
                                              );
  [session setActive:YES error:&amp;error];
  </code></pre>
  
  <p>The problem is while recording, I can only hear the background music through the ear speaker instead of the regular speaker.</p>
  
  <p>How can I set the regular speaker to work so that the recording session won't be interrupted?</p>