ReferenceScripting APIMotionSceneloadSound
MotionScene.loadSound
methodLoads a sound file of the scene's folder, decoded as the scene opens.
| Name | loadSound |
|---|---|
| Kind | method of MotionScene |
| Called as | scene.loadSound(…) |
| Since | 0.3 |
Syntax
loadSound( file: string, options?: { bus?: string }): MotionSoundParameters
| Name | Type | Description |
|---|---|---|
file | string | The 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
Notes from the community
Written by creators and checked by the docs' editors. Not part of Motion's official reference.