I want to play multiple MP3 files, in sequence (one after the other) , using AVAudioPlayer. I tried it, and it stops after playing the first MP3. However, if I go into debugger, it works fine.. any ideas? I read somewhere AVAudioPlayer plays audio in the background.. how do I prevent it from doing this? Vas
It would help to see your code. Somethings to look at - are you using one AVAudioPlayer per sound?
When you play mp3 files only one can play at a time so any over lap may not give expected results.
Not sure why the debugger would make a difference unless you mean in the simulator too. Maybe the simulator can play multiple mp3 files concurrently (since that is a result of mp3 decoding hardware in the iPhone).
Well more info will help us find a solution so feel free to post som code.
The following code ONLY plays one sound - ignores the other. Im very new to IPHONE sdk - ive scoured the web looking for a working example - Please GURUS of OBJC please help a poor Padawan learner. IPhone SDK 2.2.1
*
(void)viewDidLoad {
path2 = [[NSBundle mainBundle] pathForResource:@"alien" ofType:@"caf"];
oplayer=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path2] error:NULL];
oplayer.delegate = self;
path = [[NSBundle mainBundle] pathForResource:@"Lotus" ofType:@"caf"];
player=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
player.delegate = self;
[oplayer play];
[player play];
}
You should use one AVAudioPlayer and let it play the next file in the sequence by implementing audioPlayerDidFinishPlaying:successfully:. You could use an array with the filenames, keeping track of your current position with a simple integer that you increment on every audioPlayerDidFinishPlaying..