Possible Duplicate:
Stop a sound using the same button that plays it
Hi, I create a button in my app that play a sound
If I click on this button while the sound is playing it starts again but don't stop the previous one, how can I stop any sound before playing the next one?
Thanks
Edit:
This is the code I use for playing the sound
-(IBAction)avviaSuono:(id)sender{ CFBundleRef mainBundle= CFBundleGetMainBundle(); CFURLRef soundFileURLRef; soundFileURLRef = CFBundleCopyResourceURL(mainBundle,(CFStringRef) @"fileName", CFSTR ("mp3"), NULL); UInt32 soundID; AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID); AudioServicesPlaySystemSound(soundID); }
that play the file fileName.mp3