Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Noisemaker

Guest
Original poster
Mar 13, 2009
498
0
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?
 
applicationDidFinishLaunching -->

Code:
 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.
 
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!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.