Stop Sound with other button

124 views Asked by At

i try to create a small JingeMachine, to play sound mp3 wav and other i use this Action on button is TouchDown:

- (IBAction)NormalApplause:(id)sender {
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soudFileURLRef;
soudFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"normalApplause" , CFSTR ("mp3"), NULL);
UInt32 sounudID;
AudioServicesCreateSystemSoundID(soudFileURLRef, &sounudID);
AudioServicesPlaySystemSound(sounudID);

}

How can stop all sound with other Button? i will can start all sound to a multiple touch, but if is possible i will stop all in a single touch.

Can Helpme please?

1

There are 1 answers

1
rckoenes On

You can't stop sound played with AudioServices, you will need to use the AVAudioPlayer.

Also if you call AudioServicesCreateSystemSoundID you will need to AudioServicesDisposeSystemSoundID to correctly dispose of the sound ref.