Last active
June 5, 2021 01:53
-
-
Save eospi/e30a2711d38b6aea99ab6abf3a10eab7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let audioFilePath = "path/to/audio/file" | |
let entity = Entity() | |
do { | |
let resource = try AudioFileResource.load(named: audioFilePath, in: nil, inputMode: .spatial, loadingStrategy: .preload, shouldLoop: true) | |
let audioController = entity.prepareAudio(resource) | |
audioController.play() | |
// If you want to start playing right away, you can replace lines 7-8 with line 11 below | |
// let audioController = entity.playAudio(resource) | |
} catch { | |
print("Error loading audio file") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment