Motion
Get Motion

ReferenceScripting APIMotionSceneloadSound

MotionScene.loadSound

method

Loads a sound file of the scene's folder, decoded as the scene opens.

NameloadSound
Kindmethod of MotionScene
Called asscene.loadSound(…)
Since0.3

Syntax

loadSound(    file: string,    options?: { bus?: string }): MotionSound

Parameters

NameTypeDescription
filestringThe file (WAV, OGG, MP3, FLAC, Opus), in the scene's folder
options{ bus?: string }Optional. Bus: the bus it plays through, as Studio's Mixer shows them ("effects" unless given)

Returns

MotionSound: the sound, to play.

Remarks

Only while the script first runs (at its top): later it gives a sound that plays nothing, and the console says so. A script that lists its sounds (export const sounds = ["sounds/chime.ogg"]) has them packed with the scene too.

Example

const chime = scene.loadSound("chime.ogg", { bus: "effects" });

See also

MotionSound · In examples: Rain Harbour