PDA

View Full Version : Playing multiple sounds




arnieterm
Feb 10, 2009, 02:05 AM
I am developing an iphone application which will play multiple sound files one by one continuously. And it will be played in background so i can not use the MVMediaPlayer as this adds a view controller to the current view that is not needed for my application. I can play a single sound file using

NSArray soundFiles = [[NSArray alloc] initWithObjects:@"first", @"second", @"third", @"fourth", nil];
--------------------------------------------------------------------------------------------------------------------------------
NSURL* audioFileUrl = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:[soundFiles objectAtIndex:0] ofType:@"aif"]];
self.AudioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:audioFileUrl error:nil];
self.AudioPlayer.delegate = self;
[self. AudioPlayer play];


The above code works perfect but how can i play other songs.I want the sounds to be played in sequence so that the second sound play at the end of first and so on Please help me it's urgent.



neil.b
Feb 10, 2009, 08:34 AM
Use the audioPlayerDidFinishPlaying delegate to step through each sound in the array.

scburns123
Feb 14, 2009, 11:25 AM
What does the code for your header file look like?