StartSound

From The Official Visionaire Studio: Adventure Game Engine Wiki

startSound

Available since: v4.0
Plays a sound file.

Lua Syntax:

startSound(sounditem, {flags=1, 
    volume = int, 
    balance = int, 
    loop = true|false, 
    offset = int})

Arguments

sounditem

"string" (string should contain 'vispath:' prefix) - Relative filename of sound which should be started.

Flags

vol/volume

Sound volume (0 ... mute, 100 ... full volume), default value is 100.

bal/balance

Sound balance (-100 ... left, 0 ... center, +100 right), default value is 0.

lop/loop

If true then loop sound, otherwise play it only once (default).

ofs/offset

Set the sound to a specific offset (seek) in milliseconds. Default value is 0.

Return Values

soundID
Unique id referencing the started sound or -1 if the sound could not be started.

Examples

Example 1: play audio file, store sound id (for later use) and update sound balance of currently started sound

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

Example 2: play audio file and set volume, balance and offset

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