How to play the next sound after the first sound is finished playing using AVAudioPlayer
How to play the next sound after the first sound is finished playing using AVAudioPlayer
- Subject: How to play the next sound after the first sound is finished playing using AVAudioPlayer
- From: Bess Ho <email@hidden>
- Date: Fri, 1 May 2009 16:45:32 -0700
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 (email@hidden)
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:
This email sent to email@hidden