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

SceneAudioAsset

SceneAudioAsset

class SceneAudioAsset
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()

Types

NameSummary
Companion
object Companion

Properties

NameSummary
canBeSpatialized
val canBeSpatialized: Boolean

Whether the audio can be positioned in 3D space
duration
val duration: Float

Length of the audio in seconds
handle
var handle: Long

Native handle to the audio asset
spatialInterface_
val spatialInterface_: SpatialInterface

Functions

NameSummary
destroy
fun destroy()

Companion

object Companion

Properties

NameSummary
spatialInterface
var spatialInterface: SpatialInterface?

Functions

NameSummary
loadLocalFile
fun loadLocalFile(filename: String): SceneAudioAsset

Loads an audio file from the local filesystem.
Did you find this page helpful?
Thumbs up icon
Thumbs down icon