Global Command: startSound

From The Official Visionaire Studio: Adventure Game Engine Wiki
(Redirected from StartSound)

Play an audio file; optionally pass property values.

Related functions getSoundId | getSoundProperty | setSoundProperty | stopSound | toggleSoundPause


startSound(soundfile [, flags])


Parameter Type/Structure Description
soundfile string Relative path to the audio file you want to play. Add the "vispath:" prefix.
flags table flags = 1 indicates flags table
balance (int) Set left/right audio balance value in the range of -100 (100% left channel) to 100 (100% right channel).
loop (bool) Set to true to loop the sound.
offset (int) Set the playtime position in milliseconds.
volume (int) Set the volume in the range of 0 (mute) to 100 (full volume).

Return values

Type Description
integer Unique id referencing the started sound, or -1 if the sound could not be started.


Example 1: Play an audio file and store the sound id for later use. Update the left/right balance of the sound while it is playing.

local mySoundId = startSound('vispath:sounds/example.ogg')
setSoundProperty(mySoundId, {flags=1, balance=40})

Example 2: Play an audio file and set balance, offset and volume.

startSound('vispath:sounds/example.ogg', {flags=1, balance=-10, offset=1000, volume=70})