I was able to get this error to go away eventually. I made a few changes and am not sure which one fixed the issue. I think the thing that ultimately fixed it for me was moving the location of the audio file in Reality Composer Pro. I had the file at the root level, and not in the "Root" folder. To fix this, I dragged and dropped the audio file onto the "Root" folder.
Another issue was that Swift didn't like my ".m4a" format. So after changing the file location, and changing the file type to ".wav", the code below ran without errors.
I still can't HEAR the audio being played in my app... so I still have a big problem, but progress was made. If anyone has any other advice I'm all ears.
var body: some View {
RealityView { content in
//let audioFilePath = "/Root/back_yard_feb_7am_m4a"
let audioFilePath = "/Root/Ocean_Sounds_wav"
let audioEntity = Entity()
do {
let entity = try await Entity(named: "WinterVivarium", in: realityKitContentBundle)
content.add(entity)
let audioEmitter = audioEntity.findEntity(named: "ChannelAudio")
let resource = try AudioFileResource.load(named: audioFilePath, from: "WinterVivarium.usda", in: realityKitContentBundle)
let AudioPlaybackController = audioEmitter?.prepareAudio(resource)
AudioPlaybackController?.play()
//Audio.Decibel = 2.0
} catch {
print("Error loading winter vivarium model and/or audio: \(error)")
}
}
}