PDA

View Full Version : Playing Sound with Startup Image?




Noisemaker
May 9, 2011, 10:44 PM
I'm working on an app, and while it's essentially finished, I'd really like to add in a startup image and a sound to play with it.

I know how to add the launch image, but what do I need to do to have the sound file play when the app is launched?



jnoxx
May 10, 2011, 02:53 AM
applicationDidFinishLaunching -->

NSString *path = [NSString stringWithFormat:@"%@%@",
[[NSBundle mainBundle] resourcePath],
@"/jad0007a.wav"];

//declare a system sound id
SystemSoundID soundID;

//Get a URL for the sound file
NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO];

//Use audio sevices to create the sound
AudioServicesCreateSystemSoundID((CFURLRef)filePath, &soundID);

//Use audio services to play the sound
AudioServicesPlaySystemSound(soundID);

got that from first google search.

Probably have to add a framework.

Noisemaker
May 10, 2011, 02:24 PM
Awesome - thanks. I knew how to play the audio, but didn't know where to stick the code for it to get it to play with the launch image.

Thanks!