How can I play a specific sound from an Array?

How can I play a specific sound from an Array?

In my app, I’ve set the option to play, when the user tap a button, an audio description when an image is recognised, but I can’t select which file I want to play. My audio file are store in inside an array<a href="https://i.stack.imgur.com/pbX55.jpg" target="_blank"><img src="https://i.stack.imgur.com/pbX55.jpg"></a>

In my app, I’ve set the option to play, when the user tap a button, an audio description when an image is recognised, but I can’t select which file I want to play. My audio file are store in inside an array

Here’s the code that I use to play the single audio file:

func listenAudio(){

guard let url = Bundle.main.url(forResource: "afraid-of-destiny", withExtension: ".mp3") else { return }

do {
    try AVAudioSession.sharedInstance().setCategory(.playback, mode: .default)
    try AVAudioSession.sharedInstance().setActive(true)

    self.player = try AVAudioPlayer(contentsOf: url, fileTypeHint: AVFileType.mp3.rawValue)

    guard let player = self.player else { return }

    player.play()

    self.audioButton.setTitle("Stop", for: UIControl.State.normal)
    self.player!.play()


} catch let error {
    print(error.localizedDescription)
}

}

I thought to use an if/else, but it doesn’t work

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

iOS App Development: How Apple's iOS 13 & Swift 5 Will Change App Development Industry

Want to know how Apple's iOS 13 & Swift 5 will change the iOS app development industry? Refer to this blog that contains in-detail information on it.

How To Build Reminders iOS App in Swift 5 for Beginners

In this video, we build the Reminders App in Swift for iOS. Learn how to use dates, local / user notifications, tableviews, and much more. From scratch to working app, we'll go over every step up toe process together.

Creating an iOS app with user presence using Node.js and Swift

In this tutorial, we are going to see how you can add user presence to an iOS application using Pusher Channels, Node.js, and Swift.