API reference
API reference
Select your platform
No SDKs available
No versions available

SceneAudioAsset Class

Modifiers: final
Represents an audio asset that can be played in a 3D scene.
SceneAudioAsset provides a way to load audio files and play them in the scene, either at specific 3D positions, attached to entities, or as background audio.
Example usage:
// 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()

Signature

class SceneAudioAsset

Properties

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

Functions

destroy ()
Signature
fun destroy()

Companion Object

Companion Object Properties

spatialInterface : SpatialInterface?
[Get][Set]
Signature
var spatialInterface: SpatialInterface?

Companion Object Functions

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
Path to the audio file relative to the app's asset directory
Returns
A new SceneAudioAsset instance
Did you find this page helpful?
Thumbs up icon
Thumbs down icon