Global Command: getSoundProperty
From The Official Visionaire Studio: Adventure Game Engine Wiki
(Redirected from GetSoundProperty (CMS))
Retrieve various properties of a sound, such as: current playtime, balance, volume, loop. Only applicable for active sounds.
Related functions | getSoundId | setSoundProperty | startSound | stopSound | toggleSoundPause |
Syntax
getSoundProperty(soundId, property)
Parameters
Parameter | Type | Supported values | Description |
---|---|---|---|
soundId | integer | Id of the sound to get property from. | |
property | string | "balance" | Get the left/right audio balance. |
"duration" | Get the total length of the sound. | ||
"loop" | Check if the sound is looping. | ||
"offset" | Get the current playtime (position from the beginning of the sound). | ||
"paused" | Check if the sound is currently paused. | ||
"playing" | Check if the sound is currently playing. | ||
"volume" | Get the volume of the sound. |
Return values
The return value depends on the passed "property" parameter:
Passed parameter | Return type | Description |
---|---|---|
"balance" | integer | Balance value in the range of -100 (100% left channel) to 100 (100% right channel). A value of 0 means 50% balance or balance could not be retrieved. |
"duration" | integer | Total length of sound in milliseconds, or -1 if the duration could not be retrieved. |
"loop" | boolean | True if the sound is looped, false if it is only played once or if the property could not be retrieved. |
"offset" | integer | Current playtime of the sound in milliseconds, or -1 if the offset could not be retrieved. |
"paused" | boolean | True if the sound is currently paused, false if it is playing or not active at all. |
"playing" | boolean | True if the sound is currently playing, false otherwise. |
"volume" | integer | Level of volume in the range of 0 (mute) to 100 (full volume). A value of -1 is returned, if the volume could not be retrieved. |
Examples
Example 1: Store the current playtime of an active sound in a variable.
-- Sound id can only be retrieved if the sound is active
local mySoundId = getSoundId("vispath:sounds/example.ogg")
local soundOffset = getSoundProperty(mySoundId, "offset")