1

I have two AVAudioPlayer to determine what sound has finished to do something after that. the first sound plays just fine but the second sound (twoPlayer) plays the sound with echo. any of you knows why or how this happend?

I have this on my .h file:

@interface myClass : UIViewController<AVAudioPlayerDelegate>
{
    AVAudioPlayer *onePlayer;
    AVAudioPlayer *twoPlayer;
}
@property (retain, nonatomic) AVAudioPlayer *onePlayer;
@property (retain, nonatomic) AVAudioPlayer *twoPlayer;


.m file:

    NSString *urlAddress = [[NSBundle mainBundle] pathForResource:@"sound" ofType:@"m4a"];

    NSURL *url = [NSURL fileURLWithPath:urlAddress];

    NSError *error;
    twoPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
    twoPlayer.delegate=self;
    twoPlayer.volume=0.5;
    if (twoPlayer == nil)
        NSLog(@"[error description]");
    else
        [twoPlayer play];

- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag {


    if (player==onePlayer) {
        [onePlayer release];
    }
    if (player==twoPlayer) {
        [numberPlayer release];
    }

}
Juan
  • 627
  • 2
  • 9
  • 27

1 Answers1

0

I found the error I was setting a UIButton with "forControlEvents:UIControlEventAllTouchEvents" and the actionw was been trigger more then once. I replace the UIButton with this forControlEvents:UIControlEventTouchDown and works just fine.

Juan
  • 627
  • 2
  • 9
  • 27