I am playing a small .wav file using the AudioToolBox.
AudioServicesPlaySystemSound (soundFileObject);
But sometimes it is not playing.
Building on user1056521's answer, use the following code:
AudioServicesPlaySystemSoundWithCompletion(soundID, ^{
AudioServicesDisposeSystemSoundID(soundID);
});
where soundID
is the SystemSoundID
value you got when you called AudioServicesCreateSystemSoundID()
.
The completion block ensures the sound was played and completed playing before it is disposed of.