title: Xcode iOS: How to reset a sound once it has played using AVFoundation
body: <p>So I made a soundboard for the hospital I work for, it plays different respitory sounds for the RT's to listen too for furthering education and for trainees.  I can stop and start the sounds fine.  The problem Im having is when the sound is complete.  You have to tap any button twice to play the next sound.  So I am wondering how you would reset soundfiles upon completion.  I am pretty new to obj-c and my gut is telling me to implement NSTime, however I cant figure out how to do it, or if this is even what I want to do.</p>
  
  <p>Thanks in advance!</p>
  
  <pre><code>- (IBAction)play {
      if (soundIsPlaying == YES) {
          [audioplayer release];
          soundIsPlaying = NO;
      }
  
      else if (soundIsPlaying == NO) {
          NSString *path = [[NSBundle mainBundle] pathForResource:@"breathe1" ofType:@"wav"];
          audioplayer=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
          audioplayer.delegate = self;
          audioplayer.volume = 1.2;
          audioplayer.numberOfLoops = 0;
          [audioplayer play];
          soundIsPlaying = YES;
      }   
  }
  </code></pre>