开发者

How to play multiple audio files using AVAudioPlayer

In my application, I am displaying multiple images in rows and columns when i click on a image i will play corresponding sound using

someName = [someName stringByAppendingFormat:@".mp3"];
[audioPlayer stop];

NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/%s", [[NSBundle mainBundle] resourcePath],[someName UTF8String]]];

NSError *error;
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
audioPlayer.delegate = self; 

When i am clicking on the one image i will get particular image sound. When i click on the another image the previous sound will be stopped and new sound corresponding the image will be played.

My requirement is when i click on the first image the sound must come and when i click on the second image the first sound must not stop and both must play and when i click on the third 开发者_开发知识库one the three sounds must play.

Please help me out


Apple recommends using an IMA4 encoded *.caf file for playing multiple sounds at once.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜