Reputation: 6066
Since the system sound player in iOS can only play one sound at a time I am using AVAudioPlayer. However, if I try to play two of the same sound, using two separate AVAudioPlayers with the same sound file, it sounds noisy.
I want to be able to play a certain sound in rapid succession if the user taps, and have it sound pleasant, with no noise.
Is it recommended to create two AVAudioPlayer instances for the same sound, or just stop the playing sound? If I stop the sound I still hear a static feedback sound when I tap the button rapidly. If I wait for silence, then tap the button once it is clear, but when I keep tapping it it gets overloaded or something.
Anyway, just trying to get a VERY simple sound to play in rapid succession and sound okay.
Any feedback is appreciated.
Upvotes: 0
Views: 620
Reputation: 6066
I solved this problem (as a work-around) by creating 2-3 AVAudioPlayer with the same sound file. In each "play" method I check to see if the first sound is still playing. If so, then play the second version, and so on. This appears to work well to my ears.
- (void)playUndo
{
if ([self isSoundMuted]) return;
if ([[self undoPlayer] isPlaying])
{
[[self undoPlayerTwo] play];
}
else
{
[[self undoPlayer] play];
}
}
Upvotes: 0