This is how I played a beep sound effect in iOS 4:
SystemSoundId beepOnSoundId;
CFURLRef soundUrl = CFBundleCopyResourceURL(
CFBundleGet
In my Constructor:
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: nil];
UInt32 doSetProperty = 1;
AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryMixWithOthers, sizeof(doSetProperty), &doSetProperty);
[[AVAudioSession sharedInstance] setActive: YES error: nil];
NSURL* musicFile = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"video-sent"
ofType:@"caf"]];
self.sentSound = [[AVAudioPlayer alloc] initWithContentsOfURL:musicFile error:nil];
[self.sentSound prepareToPlay];
The function playSentSound
- (void)playSentSound
{
DLog(@"PLay Sound %@", self.sentSound);
[self.sentSound play];
}
then later in the code i just call it
[self playSentSound];
The key here are the first 4 lines ... ;-)