Playing Sound with Startup Image?

Discussion in 'iOS Programming' started by Noisemaker, May 9, 2011.

  1. Noisemaker Guest

    Mar 13, 2009
    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?
  2. jnoxx macrumors 65816


    Dec 29, 2010
    Aartselaar // Antwerp // Belgium
    applicationDidFinishLaunching -->

     NSString *path = [NSString stringWithFormat:@"%@%@", 
    					  [[NSBundle mainBundle] resourcePath],
    	//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
    got that from first google search.

    Probably have to add a framework.
  3. Noisemaker thread starter Guest

    Mar 13, 2009
    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.


Share This Page