Playing Audio When App Starts

Discussion in 'iOS Programming' started by danmwall, Apr 16, 2009.

  1. macrumors newbie

    Joined:
    Apr 13, 2009
    #1
    I have seen many apps that play a sort of "theme song" when they start up. I am able to play sounds when a button is pressed, but how to I get one to play at startup? It's a 30 second wav file, so I figured I could use the AudioServicesPlaySystemSound command. I put the following code in the viewDidLoad method of my View Controller. What am I missing?

    CFBundleRef mainBundle;
    mainBundle = CFBundleGetMainBundle ();

    themeSoundFileURLRef = CFBundleCopyResourceURL (mainBundle, CFSTR ("ThemeSong"), CFSTR ("wav"), NULL);
    AudioServicesCreateSystemSoundID (themeSoundFileURLRef, &themeSoundFileObject);
    AudioServicesPlaySystemSound (self.themeSoundFileObject);
     

Share This Page