My app plays mp3 files in sequence. I finally managed to play mp3 files in sequence. Additionally, I need to show simple text on my app depending on the mp3 file.
For example, when 0.mp3 file is played, textlabel.text shows "hello" from textarray. after the 0.mp3 is played, when 1.mp3 file is played, textlabel.text shows "nice to meet you" from textarray.
How to show simple sentences on the text label depending on the audio file, one after another?
textarray = ["hello" , "nice to meet you" , "my name is James" , "how old are you?"]
@IBAction func autoplay(_ sender: Any) {
var items : [AVPlayerItem] = []
for number in myIndex..<arr.count {
let url = Bundle.main.url(forResource: String(number), withExtension: "mp3")!
items.append(AVPlayerItem(url: url))
textlabel.text = textarry[number]
}
queue = AVQueuePlayer(items: items)
queue.play()
}