Step 1: Add framework: AudioToolbox.framework
Step 2: use function play sound file with name: "push.wav"
+ (void) playSound
{
SystemSoundID soundID;
NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"push" ofType:@"wav"]; CFURLRef soundUrl = (__bridge CFURLRef) [NSURL fileURLWithPath:soundPath];
//Use audio sevices to create the sound
AudioServicesCreateSystemSoundID((CFURLRef)soundUrl, &soundID); //Use audio services to play the sound
AudioServicesPlaySystemSound(soundID); AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
}
No comments:
Post a Comment