How can I add more than two player
s into one function? just like a dial tone, I need the player
s 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.