I'm new to iphone development. i want to write an app that has 3 buttons. touching each will trigger a sound.
- 1.wav
- 2.wav
- 3.wav
Can someone give me some hints and guide me to the right path?
I'm new to iphone development. i want to write an app that has 3 buttons. touching each will trigger a sound.
- 1.wav
- 2.wav
- 3.wav
Can someone give me some hints and guide me to the right path?
You will want to write actions in a controller that trigger the sounds and hook the buttons up to those actions.
Here is the sample code to play .wav files on button click event:
-(void) playWavFile{
SystemSoundID soundFileObject;
CFURLRef soundFileURLRef = CFBundleCopyResourceURL (CFBundleGetMainBundle (),CFSTR ("1"),CFSTR ("wav"),NULL );
AudioServicesCreateSystemSoundID (soundFileURLRef,&soundFileObject );
AudioServicesPlaySystemSound (soundFileObject);
}
-(IBAction) button1Pressed:(id)sender
{
[self playWavFile];
}
Thanks,
Jim.