title: audioplayerdidfinishplaying problem! iphone sdk
body: <p>
  
  After a sound has finished, another sound could play...but in this code sounds are mixing...How can I fix it?
  
  </p>
  
  <pre><code>-(IBAction) ... {
     for ( ...) {
       if (compare(Output, N1)) {
         songPath = [[NSBundle mainBundle] pathForResource:@"a" ofType:@"wav"];
       }
       if (compare(Output, N2)) {
         songPath = [[NSBundle mainBundle] pathForResource:@"b" ofType:@"wav"];
       }
       audioPlayer=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath: songPath] error:NULL];
                  [audioPlayer setDelegate:self];
                  [audioPlayer play];
     }
  }
  
  
  -(void) audioPlayerDidFinishPlaying: (AVAudioPlayer *) player successfully: (BOOL) flag {
    NSLog(@"Song FINISHED!!!!!!");
    [player release];
  }
  </code></pre>