Skip to main content

Posts

Showing posts with the label Play Audio

Play Audio File in iPhone application

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];    }