This is how I played a beep sound effect in iOS 4:
SystemSoundId beepOnSoundId;
CFURLRef soundUrl = CFBundleCopyResourceURL(
CFBundleGetMainBundle(),
CFSTR("beep"),
CFSTR("wav"),
NULL
);
// soundUrl logged:
// file://localhost/var/mobile/Applications/ ... beep.wav
AudioServicesCreateSystemSoundID(soundUrl, &beepOnSoundId);
// beepOnSoundId logged: 4097
AudioServicesPlaySystemSound(beepOnSoundId);
It stopped working, when I upgraded my device to iOS 5. I hear nothing. I logged out all the variables and none were nil or 0.
How has the API changed in iOS 5 that breaks my sound playing code?
Update
The problem may be because I have an AVCaptureSession
running while I play the sound. iOS 5 somehow doesn't let you do this anymore. I need to play a beep sound while I am recording something from the camera.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…