1

I am attempting to make a UIButton that will systematically play 4 sounds in a specific order, each one after pressing the UIButton. I tried doing this by using the code:

var counter = 0

    @IBAction func buttonTapped(sender: AnyObject) {

        counter = counter + 1


        if counter == 1 {
            print("play 1_barbradycarryon.wav")
        }else if counter == 2{
            print("play 2_fooledyou.wav")
        }else if counter == 3 {
            print("play 3_Looney.wav" )
        }else if counter == 4 {
            print("play 4_sucks.wav")
        }
    }

But I had no luck. What code should I use? And, if needed, how should I insert AVAudioPlayer into the script (So far, I did not insert AVAudioPlayer; mostly because I do not know how in this scenario)? I am a new coder and would appreciate any help!

rmaddy
  • 314,917
  • 42
  • 532
  • 579
davidionita
  • 85
  • 1
  • 9

0 Answers0