PDA

View Full Version : AudioServicesPlaySystemSound(soundID) - How to STOP a sound?




ethana
Dec 18, 2008, 12:11 AM
AudioServicesCreateSystemSoundID((CFURLRef)filePath, &soundID);
AudioServicesPlaySystemSound(soundID);

I am playing a sound effect that is about 5 seconds long with the calls above. How do I stop the sound right in the middle of it playing?

Ethan



bigsprocket
Dec 18, 2008, 02:50 PM
You can't. If you can target the 2.2 SDK, you can use the AVAudioPlayer class, which makes manipulating sound a LOT easier than it was in 2.0/2.1

http://developer.apple.com/iphone/library/documentation/AVFoundation/Reference/AVAudioPlayerClassReference/Reference/Reference.html

Niiro13
Dec 18, 2008, 05:38 PM
There's no method to pause it (which is why most people use AudioQueue or OpenAL) or stop it (in a sense where you're simply stopping the sound ready to be played again), but you can use the AudioServicesDisposeSystemSoundID which will theoretically stop the sound.

neil.b
Dec 19, 2008, 08:45 AM
Another vote for AVAudio here.