Add the Framwork:
AVFoundation.framework
AudioToolbox.framework
Import :
AudioToolbox/AudioToolbox.h
AVFoundation/AVFoundation.h
+(void) playSound :(NSString *)soundFileName{
NSString *pathForSilentFile = [[NSBundle mainBundle] pathForResource:soundFileName ofType:@"wav"];
NSURL *soundFile = [[NSURL alloc] initFileURLWithPath:pathForSilentFile];
AVAudioPlayer *sPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFile error:NULL];
[soundFile release];
[sPlayer prepareToPlay];
[sPlayer play];
}
AVFoundation.framework
AudioToolbox.framework
Import :
AudioToolbox/AudioToolbox.h
AVFoundation/AVFoundation.h
+(void) playSound :(NSString *)soundFileName{
NSString *pathForSilentFile = [[NSBundle mainBundle] pathForResource:soundFileName ofType:@"wav"];
NSURL *soundFile = [[NSURL alloc] initFileURLWithPath:pathForSilentFile];
AVAudioPlayer *sPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFile error:NULL];
[soundFile release];
[sPlayer prepareToPlay];
[sPlayer play];
}
Comments
Post a Comment