Hi guys, I've been this app for quite a while and I wanted to add audio to it but I've encountered a strange bug. Whenever I try to play the audio from the testing device, it prints out that the audio file cannot be found. I've checked multiple times the names and the code and I get no errors there whatsoever. I have no idea what might be causing this. Here's a part of the code: `import SwiftUI import AVFoundation
struct Card: Identifiable {
let id = UUID()
let heading: String
let description: String
let imageName: String
let detailDescription: String
let sonification: String
}
struct ExplorepageUI: View {
@State private var selectedCard: Card?
@State private var showMore = false
@State private var currentIndex = 0
@State private var currentCards: [Card] = []
let galaxies = [
Card(heading: "The Mice Galaxies",
description: "They’re located about 300 million light-years away in the constellation Coma Berenices.",
imageName: "TheMiceGalaxiesHubble",
detailDescription:"""
Their name refers to the long tails produced by tidal action, the relative difference between gravitational pulls on the near and far parts of each galaxy, known here as a galactic tide. It is a possibility that both galaxies, which are members of the Coma Cluster, have experienced collision, and will continue colliding until they coalesce. The colors of the galaxies are peculiar. In NGC 4676A a core with some dark markings is surrounded by a bluish white remnant of spiral arms. The tail is unusual, starting out blue and terminating in a more yellowish color, despite the fact that the beginning of each arm in virtually every spiral galaxy starts yellow and terminates in a bluish color. NGC 4676B has a yellowish core and two arcs; arm remnants underneath are bluish as well.
The galaxies were photographed in 2002 by the Hubble Space Telescope. In the background of the Mice Galaxies, there are over 3000 galaxies, at distances up to 13 billion light-years.
""",
sonification: "SonificationoftheMiceGalaxies"),
`class MusicPlayer: ObservableObject { private var audioPlayer: AVPlayer?
func playSound(named sonificationFileName: String){
if let url = Bundle.main.url(forResource: sonificationFileName, withExtension: "mp3"){
print("✅ Found audio file at: \(url)")
audioPlayer = try? AVPlayer(url: url)
audioPlayer?.play()
print("🎵 Audio should now be playing!")
} else {
print("❌ Audio file not found: \(sonificationFileName).mp3")
}
}
func pause(){
audioPlayer?.pause()
}
}