tags:

views:

191

answers:

1

I'm trying to display an image while a sound is playing. I can get it to appear, but I'm having trouble making it disappear once the sound has finished playing.

My code:

-(IBAction)guitarChord:(id)sender
{
    if (theAudio.playing == YES) {
        theAudio.stop;
        theAnimation.stop;
    } else {
        theAudio.play;   
        theAnimation.play;   
    }
}

I'm using AVAudioPlayer.

Any ideas what I am doing wrong?

How do I detect a sound has stopped?

+1  A: 

Briefly, you need to take a look at AVAudioPlayerDelegate and audioPlayerDidFinishPlaying.

John Fricker
Thanks, John! That was easy :)