Simple sound effect loop using AudioToolKit

Posted by Typeoneerror on Stack Overflow See other posts from Stack Overflow or by Typeoneerror
Published on 2010-06-12T16:55:08Z Indexed on 2010/06/12 17:03 UTC
Read the original article Hit count: 263

I've created a few sounds for use in my game. I can play them at certain events without issue:

// create sounds
CFBundleRef mainBundle;
mainBundle = CFBundleGetMainBundle();

_soundFileShake = CFBundleCopyResourceURL(mainBundle, CFSTR("shake"), CFSTR("wav"), NULL);
AudioServicesCreateSystemSoundID(_soundFileShake, &_soundIdShake);

// later...
AudioServicesPlaySystemSound(_soundIdShake);

The game has a mechanism which allows you to shake the device to activate some functionality. I've got the shaking code done so I get get a "shaking started" and "shaking ended" message to my game. What I need to have happen is start playing "shave.wav" when shaking starts and loop it until it stops. Is there a way to do this with AudioToolbox/AudioServices? How could I do this if not?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about audio