Playing Sound with Startup Image?

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

  1. Guest

    Joined:
    Mar 13, 2009
    #1
    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. macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #2
    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.
     
  3. thread starter Guest

    Joined:
    Mar 13, 2009
    #3
    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!
     

Share This Page