Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

99miles

macrumors member
Original poster
Oct 10, 2008
50
0
Hello-
I'm using AVAudioPlayer to play sounds (SDK 2.2.1). Below if the code I'm using that's in a method that is called when I touch the screen. I stop any sounds that's already playing to play a new one if the touch occurs while another sounds is already playing.

The problem is that every 3-5 times that I start a sound, the sound completes and then starts looping the last little bit of the sound. It sounds like a cd skipping. I've spent 3 hours trying different things, and Googling brings up nothing. Any ideas? Thanks in advance!

Code:
int soundNum			= arc4random() % [soundsArray count];
AVAudioPlayer *sound	= [soundsArray objectAtIndex:soundNum];

[currentSound stop];
currentSound = nil;

currentSound = sound;
[currentSound setCurrentTime:0.0];
[currentSound play];
 
I'm having the same problem

I'm having the same problem.
iPod touch, SDK 2.2.1. Exactly same problem.
I used mp3 sample files at first time and it started skipping (looping end of the sound)
occasionally. maybe once out of a dozen of times. and then converted all media to aac/caf format using afconvert. This time the problem happens once in twice. Code is fairly simple and straightforward, no much room for error.
It loads audio file one at a time and play it. when it is finished (or error occurs), play next audio file.

Please let me know if a solution is found.
Thanks
 
The problem went away for me when I used wav files instead of caf. Really irritating. Good luck!
 
Thank you for the info.
In my case, using wav is not really an option. size of audio files are already too much.

I tried to convert original wave to mp3 and caf and m4a using aac codec. using caf, almost 100% of the looping problem but with m4a the chances were a little lower. Tried to change channels and bitrates but no difference.

So media container format matters. That's all I figured out so far..sigh.
SDK 2.2 is causing me too much trouble.
I will update when i find anything new.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.