问题
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
回答1:
Apple recommends using an IMA4 encoded *.caf file for playing multiple sounds at once.
来源:https://stackoverflow.com/questions/3744826/how-to-play-multiple-audio-files-using-avaudioplayer