I have AVFoundation
and AudioToolbox
frameworks added to my project. In the class from where I want to play a system sound, I #include <AudioToolbox/AudioToolbox.h>
and I call AudioServicesPlaySystemSound(1007);
. I'm testing in a device running iOS 8
, sounds are on and volume is high enough, but I don't hear any system sound when I run the app and AudioServicesPlaySystemSound(1007);
is called... what could I be missing?
With iOS10 playing audio like this doesn't work:
SystemSoundID audioID;
AudioServicesCreateSystemSoundID((__bridge CFURLRef)pathURL, &mySSID);
AudioServicesPlaySystemSound(audioID);
Use this instead:
AudioServicesCreateSystemSoundID((__bridge CFURLRef)pathURL, &audioID);
AudioServicesPlaySystemSoundWithCompletion(audioID, ^{
AudioServicesDisposeSystemSoundID(audioID);
});