AudioFileResource.load not working

Hello everybody, I'm trying to add sound effects to entities but I'm not being able to load audio assets from URL or main bundle Url, here's my code:

let resource = try AudioFileResource.load(contentsOf: audioFileURL, withName: path, inputMode: .spatial, loadingStrategy: .preload, shouldLoop: true)

            let audioController = entity.prepareAudio(resource)

            audioController.play()

        } catch {

            print("Error while loading audio file...")

        }

where this is my URL:

file:///var/mobile/Containers/Data/Application/B338F8B5-2FC6-4B90-9720-271E5362906A/Documents/Griffin.wav.

any help would be very appreciate, thanks you so much!

Replies

Hello,

There are a couple of things that you should check:
  1. Make sure that the entity that you are playing your audio on has been added to the scene and is active in the scene, (i.e. check that isActive reports true for that entity.

  2. Make sure you don't have the mute switch enabled on your device.