Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

I want to play audio files, but would like to play them one after another. I saw some things, but it

jls00jls00 Posts: 1New Users
-(IBAction)LO:(id)sender{


CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;

soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @LO, CFSTR ("wav"), NULL);

UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);

}

-(IBAction)KEN:(id)sender {
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @KEN, CFSTR ("wav"), NULL);

UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}
Tagged:

Replies

  • baja_yubaja_yu San FranciscoPosts: 6,215Moderators, Registered Users Admin
    Please type your message/problem description in the body of the thread not the title.
  • Duncan CDuncan C Posts: 9,114Tutorial Authors, Registered Users @ @ @ @ @ @ @
    jls00 said:

    -(IBAction)LO:(id)sender{


    CFBundleRef mainBundle = CFBundleGetMainBundle();
    CFURLRef soundFileURLRef;

    soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @LO, CFSTR ("wav"), NULL);

    UInt32 soundID;
    AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
    AudioServicesPlaySystemSound(soundID);

    }

    -(IBAction)KEN:(id)sender {
    CFBundleRef mainBundle = CFBundleGetMainBundle();
    CFURLRef soundFileURLRef;
    soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @KEN, CFSTR ("wav"), NULL);

    UInt32 soundID;
    AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
    AudioServicesPlaySystemSound(soundID);
    }

    jls00 said:

    -(IBAction)LO:(id)sender{


    CFBundleRef mainBundle = CFBundleGetMainBundle();
    CFURLRef soundFileURLRef;

    soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @LO, CFSTR ("wav"), NULL);

    UInt32 soundID;
    AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
    AudioServicesPlaySystemSound(soundID);

    }

    -(IBAction)KEN:(id)sender {
    CFBundleRef mainBundle = CFBundleGetMainBundle();
    CFURLRef soundFileURLRef;
    soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @KEN, CFSTR ("wav"), NULL);

    UInt32 soundID;
    AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
    AudioServicesPlaySystemSound(soundID);
    }

    Your subject got cut off, and the body of your message is nothing but code that is not in code tags. It makes it a bit hard to figure out what you are trying to ask.

    I would suggest using AVAudioPlayer objects, not audio services. If you create an audio player, you can set yourself up as the delegate. Then you get a message ( audioPlayerDidFinishPlaying:successfully: ) when the sound is done playing.

    If all your sounds will fit in memory at once, you could create a mutable array of audio players, and write a method that would remove the first audio player from the array and start it playing, until the array is empty.
    Regards,
    Duncan C
    WareTo

    widehead.gif
    Animated GIF created with Face Dancer, available for free in the app store.

    I'm available for one-on-one help at CodeMentor
Sign In or Register to comment.