How do you play the next sound after the end of sound file? This code play 2
sound files at the same time. audioPlayerDidFinishPlaying only run at the
end of 1st sound file.

- (IBAction) playSound:(id)sender{
    int i;
    for (i=1; i<3; i++) {
    NSString *soundFilePath = [[NSString alloc] initWithFormat:@"sample%i",
i];
    NSString *soundPath = [[NSBundle mainBundle]
pathForResource:soundFilePath ofType:@"caf"];
    player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL
fileURLWithPath: soundPath] error:nil];
    [player setDelegate:self]; // Notify Delegate for
audioPlayerDidFinishPlaying
    [player prepareToPlay];
    [player play];
    }
}

- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer*)player successfully:
(BOOL)flag
{
    if (player == playSound)
    NSLog(@"Finish playing");
}
-- 
Bess Ho
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to