// Load an audio file
val audioAsset = SceneAudioAsset.loadLocalFile("data/common/audio/click.ogg")
// Play the sound at a specific position in 3D space
scene.playSound(audioAsset, Vector3(0f, 1.7f, -1f), volume = 0.8f)
// Play the sound attached to an entity
scene.playSound(audioAsset, myEntity, volume = 1.0f)
// Play the sound attached to the user (non-spatialized)
scene.playSound(audioAsset, volume = 0.5f)
// Play looping background music
scene.playBackgroundSound(audioAsset, volume = 0.3f, looping = true)
// When done with the asset, release resources
audioAsset.destroy()
class SceneAudioAsset
canBeSpatialized
:
Boolean
[Get] |
Whether the audio can be positioned in 3D space
Signature
val canBeSpatialized: Boolean |
duration
:
Float
[Get] |
Length of the audio in seconds
Signature
val duration: Float |
handle
:
Long
[Get] |
Native handle to the audio asset
Signature
var handle: Long |
spatialInterface_
:
SpatialInterface [Get] |
Signature
val spatialInterface_: SpatialInterface |
destroy
()
|
Signature
fun destroy() |
spatialInterface
:
SpatialInterface? [Get][Set] |
Signature
var spatialInterface: SpatialInterface? |
loadLocalFile
(
filename
)
:
SceneAudioAsset |
Loads an audio file from the local filesystem.
The file path is relative to the application's asset directory. OGG and WAV formats supported.
Signature
fun loadLocalFile(filename: String): SceneAudioAsset Parameters
filename:
String
|