2

How can I add more than two players into one function? just like a dial tone, I need the players to be in a row and have a bit of pause between of them. here's what I've done so far:

import UIKit
import AVFoundation
import CoreData


class FirstViewController: UIViewController {

var player:AVAudioPlayer?

var player2:AVAudioPlayer?

var player3:AVAudioPlayer?

var player4:AVAudioPlayer?

var secondSoundTimer: Timer?

@IBAction private func play(_ sender: Any) {

    stopPlaying()

    player?.play()
    secondSoundTimer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: false) {timer in
        self.player2?.play()
        self.secondSoundTimer?.invalidate()
        self.secondSoundTimer = nil
    }
}

I tried to use the thirdSoundTimer and so on but I don't know how to use it correctly.

OOPer
  • 47,149
  • 6
  • 107
  • 142
Shahin
  • 71
  • 2
  • 11

0 Answers0