views:

185

answers:

1
SystemSoundID soundID;
NSString *path = [[NSBundle mainBundle] pathForResource:@"static" ofType:@"caf"]; 
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path], &soundID);
AudioServicesPlaySystemSound(soundID);

I have implemented above code in my application.

It works perfectly,

But the problem is I don't know how to stop it.

i.e Sound is of 10 sec.

Before 10 sec. if user taps button, sound should be stopped?

How?

Thanks in advance.

sagar

+1  A: 

Try AudioServicesDisposeSystemSoundID, it stops sounds immediately. You'll need to recreate the sound if you intend to use it again.

mikestew