title: Xcode 4.2 Soundboard
body: <p>I'm trying to create a Soundboard app, but I'm having difficulty finding a way to play sounds and making the sound stop when the other sound button is pressed. I want to prevent the sound from overlapping each other. And each sound will loop. Is there a way to prevent more than one sound playing at the same time? I have not found a way in any tutorials. The code I'm using for the soundboard looks a little like this:</p>
  
  <pre><code>-(IBAction)sound1 {
  CFBundleRef mainBundle = CFBundleGetMainBundle();
  CFURLRef soundFileURLRef;
  soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"sound1", CFSTR      ("wav"), NULL);
  
  UInt32 soundID;
  AudioServicesCreateSystemSoundID(soundFileURLRef, &amp;soundID);
  AudioServicesPlaySystemSound(soundID);
  }
  
  -(IBAction)sound2 {
  CFBundleRef mainBundle = CFBundleGetMainBundle();
  CFURLRef soundFileURLRef;
  soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"sound2", CFSTR      ("wav"), NULL);
  
  UInt32 soundID;
  AudioServicesCreateSystemSoundID(soundFileURLRef, &amp;soundID);
  AudioServicesPlaySystemSound(soundID);
  }
  </code></pre>