Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
502 views
Welcome To Ask or Share your Answers For Others

1 Answer

This bug report could be related to your question, if you have an AVCaptureSession running.

Under iOS 5, when using an AudioServicesPlaySystemSound call, it will not work when there is an active AVCaptureSession with an audio device active.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...