Reputation: 673
I am using AVAudioPlayer, When i pressed button, the sound is playing but its lazy(or giving me late feedback), How can i play sound with rapid feedback..Thanks
Upvotes: 0
Views: 174
Reputation: 2927
Try Like this...
In .h
AVAudioPlayer *playerBG
In .m
AVAudioPlayer *pp = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Ting" ofType:@"wav"]] error:nil];
self.playerBG = pp;
[pp prepareToPlay];
[pp release];
Upvotes: 1
Reputation: 13310
Are you calling prepareToPlay
before trying to play the sound? As the method suggests this does all the preparation, meaning subsequent calls to play
should be very quick.
If you need even lower latency, you may need to use AVAudioQueues though.
Upvotes: 1