Playing wav files with AudioServices in iPhone
Posted
by Biranchi
on Stack Overflow
See other posts from Stack Overflow
or by Biranchi
Published on 2010-04-19T12:27:30Z
Indexed on
2010/04/19
13:33 UTC
Read the original article
Hit count: 342
Hi All,
I am trying to play two .wav files in my appllication, but i am only able to play the first wav file , the second file is not at all playing.
I have added the AudioToolbox framework. In my .h file i have included the Audiotoolbox.h file and has the following declarations
//Beep Sound
SystemSoundID soundFileObject;
SystemSoundID recycleFileObject;
In my .m file i am registering both the wav files as following
CFURLRef soundFileURLRef = CFBundleCopyResourceURL (CFBundleGetMainBundle (),CFSTR ("Beep"),CFSTR ("wav"),NULL );
AudioServicesCreateSystemSoundID (soundFileURLRef,&soundFileObject );
CFURLRef soundFileURLRef2 = CFBundleCopyResourceURL (CFBundleGetMainBundle (),CFSTR ("Recycle"),CFSTR ("wav"),NULL );
AudioServicesCreateSystemSoundID (soundFileURLRef2,&recycleFileObject );
And i have written two methods for playing each file individually.
-(void)playBeepSound
{
NSLog(@"Beep sound called : %d", soundFileObject);
AudioServicesPlaySystemSound (soundFileObject);
}
-(void)playRecycleSound
{
NSLog(@"Recycle sound called : %d", recycleFileObject);
AudioServicesPlaySystemSound (recycleFileObject);
}
But i am only able to play the Beep sound , but not the second sound wav file.
What is the error ???
Thanks
© Stack Overflow or respective owner