1
votes

I have an iPhone application which requires me to play a looping mp3 sound during the entire lifetime of app.

But based on some actions performed by user this mp3 should stop/pause for while & another mp3 should play & then this mp3 should resume playing again.

I havent really used any audio API on iPhone yet, I've just used AudioToolbox for playing sounds on button taps thats all.

So what do you guys recommend I should do. Any pointers...? suggestions....?

1

1 Answers

1
votes

just as I wrote in this post, you can use AVAudioPlayer

code extract:

NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:@"mySound" ofType:@"mp3"];
NSURL *soundFileURL = [NSURL URLForString:soundFilePath];
AVAudioPlayer *player = [[AVAudioPlayer alloc]initWithContentsOfURL:soundFileURL];
player.numberOfLoops = -1; //infinite

[player play];

and you can pause it with:

[player pause];