Playing short sound

Discussion in 'iOS Programming' started by guyddor, Aug 23, 2009.

  1. guyddor macrumors member

    Joined:
    Jan 7, 2009
    #1
    Hi,

    I need to right code to play a short sound.
    I have been already added the AudioToolBox framework to my project and a short sound audio file.
     
  2. Kingbombs macrumors member

    Joined:
    Jun 24, 2009
    #2
    Look at the apple doc's
    Then make an attempt at trying to do it yourself, and use google when you get errors
    then when you are stuck post on here what you have tried.
    You will learn it 100 times quicker and better that way (rather than pasting in code that you don't understand)
     
  3. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
  4. Rynnakat macrumors newbie

    Joined:
    Aug 24, 2009
    #4
    I am having the same problem. I have been watching tutorials online. Can anyone see an issue with this code?
    Code:
    - (IBAction)Playsound:(id)sender
    {
    	CFBundleRef mainBundle = CFBundleGetMainBundle();
    	CFURLRef soundFileURLRef;
    	soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"sound", CFSTR("mp3"), NULL);
    	if (soundFileURLRef) {
    		CFStringRef url = CFURLGetString(soundFileURLRef);
    	}
    	UInt32 soundID;
    	AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
    	AudioServicesPlaySystemSound(soundID);
    	
    Luv,
    Miss Kat
     
  5. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #5
    What exactly is it not doing?
     

Share This Page