Playing multiple sounds

Discussion in 'iOS Programming' started by arnieterm, Feb 10, 2009.

  1. arnieterm macrumors regular

    Aug 28, 2008
    I am developing an iphone application which will play multiple sound files one by one continuously. And it will be played in background so i can not use the MVMediaPlayer as this adds a view controller to the current view that is not needed for my application. I can play a single sound file using

    NSArray soundFiles = [[NSArray alloc] initWithObjects:mad:"first", @"second", @"third", @"fourth", nil];
    NSURL* audioFileUrl = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:[soundFiles objectAtIndex:0] ofType:mad:"aif"]];
    self.AudioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:audioFileUrl error:nil];
    self.AudioPlayer.delegate = self;
    [self. AudioPlayer play];

    The above code works perfect but how can i play other songs.I want the sounds to be played in sequence so that the second sound play at the end of first and so on Please help me it's urgent.
  2. neil.b macrumors member


    Nov 20, 2008
    Use the audioPlayerDidFinishPlaying delegate to step through each sound in the array.
  3. scburns123 macrumors newbie

    Nov 13, 2006
    Header File

    What does the code for your header file look like?

Share This Page